diff --git a/.github/actions/unit-tests/action.yml b/.github/actions/unit-tests/action.yml index 02ac242d..1850b066 100644 --- a/.github/actions/unit-tests/action.yml +++ b/.github/actions/unit-tests/action.yml @@ -12,3 +12,7 @@ runs: run: | npm run test:unit shell: bash + - name: Run type tests + run: | + npm run test:types + shell: bash diff --git a/package-lock.json b/package-lock.json index 051930ec..9098d4f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "7.17.1", "license": "Apache-2.0", "dependencies": { + "kuzzle-types": "1.0.0-beta.1", "ws": "8.18.3" }, "devDependencies": { @@ -6280,6 +6281,12 @@ "seed-random": "~2.2.0" } }, + "node_modules/kuzzle-types": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/kuzzle-types/-/kuzzle-types-1.0.0-beta.1.tgz", + "integrity": "sha512-rqUqhhK/iF9wHoqRSnryNV1hG63f3HpWWZoq+oLCT4LQlvfi8AGpkFbbQ0NvNio83/Qm70kwKHnubF95lBXZPQ==", + "license": "Apache-2.0" + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", diff --git a/package.json b/package.json index c13d0958..0635bfac 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,9 @@ ], "scripts": { "prepublishOnly": "npm run build", - "test": "npm run test:lint && npm run test:unit && npm run test:functional", + "test": "npm run test:lint && npm run test:unit && npm run test:types && npm run test:functional", "test:unit": "nyc --reporter=text-summary --reporter=lcov mocha", + "test:types": "tsc -p test/types/tsconfig.json", "test:functional": "cucumber-js --exit --fail-fast -c cucumber.config.cjs", "test:lint": "eslint . --fix", "build": "tsc --build tsconfig.json && vite build", @@ -42,6 +43,7 @@ }, "license": "Apache-2.0", "dependencies": { + "kuzzle-types": "^1.0.0-beta.1", "ws": "8.18.3" }, "devDependencies": { diff --git a/src/types/ApiKey.ts b/src/types/ApiKey.ts index 49bed04a..c950bb3a 100644 --- a/src/types/ApiKey.ts +++ b/src/types/ApiKey.ts @@ -1,36 +1,3 @@ -/** - * ApiKey - * - * @see https://docs.kuzzle.io/core/2/guides/advanced/api-keys/ - */ -export type ApiKey = { - /** - * ApiKey unique ID - */ - _id: string; - /** - * ApiKey content - */ - _source: { - /** - * User kuid - */ - userId: string; - /** - * Expiration date in Epoch-millis format (-1 if the token never expires) - */ - expiresAt: number; - /** - * Original TTL in ms - */ - ttl: number; - /** - * API key description - */ - description: string; - /** - * Authentication token associated with this API key - */ - token: string; - }; -}; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { ApiKey } from "kuzzle-types"; diff --git a/src/types/ArgsDefault.ts b/src/types/ArgsDefault.ts index 0b5c6527..ab92801e 100644 --- a/src/types/ArgsDefault.ts +++ b/src/types/ArgsDefault.ts @@ -1,10 +1,3 @@ -/** - * Generic API action arguments - */ -export interface ArgsDefault { - queuable?: boolean; - - timeout?: number; - - [name: string]: any; -} +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { ArgsDefault } from "kuzzle-types"; diff --git a/src/types/BaseRequest.ts b/src/types/BaseRequest.ts index 419a46f9..f2718217 100644 --- a/src/types/BaseRequest.ts +++ b/src/types/BaseRequest.ts @@ -1,9 +1,3 @@ -import { JSONObject } from "./JSONObject"; - -export interface BaseRequest extends JSONObject { - controller: string; - - action: string; - - body?: JSONObject; -} +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { BaseRequest } from "kuzzle-types"; diff --git a/src/types/Document.ts b/src/types/Document.ts index 339bc939..fe344468 100644 --- a/src/types/Document.ts +++ b/src/types/Document.ts @@ -1,23 +1,9 @@ -import { JSONObject } from "./JSONObject"; -import { KDocumentKuzzleInfo } from "./KDocument"; +import type { DocumentContent, JSONObject } from "kuzzle-types"; -/** - * Kuzzle metadata - * - * @deprecated Use "KDocumentKuzzleInfo" - */ -export interface DocumentMetadata { - _kuzzle_info?: Partial; -} - -/** - * Represents the `_source` property of the document - * - * @deprecated Create an interface extending "KDocumentContent" - */ -export interface DocumentContent extends DocumentMetadata { - [key: string]: JSONObject | any; -} +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). `Document` stays here: it is a class, a runtime +// value, which the types-only kuzzle-types declares as an interface. +export type { DocumentContent, DocumentMetadata } from "kuzzle-types"; /** * Kuzzle document diff --git a/src/types/HttpRoutes.ts b/src/types/HttpRoutes.ts index 0ccb3713..53743cbb 100644 --- a/src/types/HttpRoutes.ts +++ b/src/types/HttpRoutes.ts @@ -1,39 +1,3 @@ -/** - * HTTP routes definition format - * - * @see https://docs.kuzzle.io/core/2/guides/develop-on-kuzzle/api-controllers/#http-routes - * - * @example - * { - * : { - * : { verb: , url: } - * } - * } - * - * { - * 'my-plugin/my-controller': { - * action: { verb: 'GET', url: '/some/url' }, - * action2: { verb: 'GET', url: '/some/url/with/:parameter' } - * } - * } - */ -export type HttpRoutes = { - /** - * Controller name - */ - [controller: string]: { - /** - * Action name - */ - [action: string]: { - /** - * HTTP verb - */ - verb: string; - /** - * URL - */ - url: string; - }; - }; -}; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { HttpRoutes } from "kuzzle-types"; diff --git a/src/types/JSONObject.ts b/src/types/JSONObject.ts index f87e9d53..5207b9a9 100644 --- a/src/types/JSONObject.ts +++ b/src/types/JSONObject.ts @@ -1,4 +1,3 @@ -/** - * An interface representing an object with string key and any value - */ -export type JSONObject = Record; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { JSONObject } from "kuzzle-types"; diff --git a/src/types/KDocument.ts b/src/types/KDocument.ts index 86236094..002c923e 100644 --- a/src/types/KDocument.ts +++ b/src/types/KDocument.ts @@ -1,83 +1,9 @@ -import { JSONObject } from "./JSONObject"; - -/** - * Represents Kuzzle Metadata. - */ -export interface KDocumentKuzzleInfo { - /** - * Kuid of the user who created the document - */ - author: string; - - /** - * Creation date in micro-timestamp - */ - createdAt: number; - - /** - * Kuid of the user who last updated the document - */ - updater: string | null; - - /** - * Update date in micro-timestamp - */ - updatedAt: number | null; -} - -/** - * Base interface for a Kuzzle document content - */ -export interface KDocumentContent { - _kuzzle_info?: KDocumentKuzzleInfo; -} - -/** - * Generic kuzzle document content - */ -export interface KDocumentContentGeneric extends KDocumentContent, JSONObject {} - -/** - * Represents a Kuzzle document - * - * Type argument represents the document content in the "_source" property - */ -export interface KDocument { - /** - * Unique ID - */ - _id: string; - - /** - * Content - */ - _source: TKDocumentContent; - - created?: boolean; - - _version?: number; -} - -/** - * Represents a Kuzzle document retrieved from search - */ -export interface KHit< - TKDocumentContent extends KDocumentContent, -> extends KDocument { - /** - * Elasticsearch relevance score - */ - _score: number; - - /** - * Document index - * Present only in the case of a multi search - */ - index?: string; - - /** - * Document collection - * Present only in the case of a multi search - */ - collection?: string; -} +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { + KDocumentKuzzleInfo, + KDocumentContent, + KDocumentContentGeneric, + KDocument, + KHit, +} from "kuzzle-types"; diff --git a/src/types/Mappings.ts b/src/types/Mappings.ts index 61193788..d7d1615e 100644 --- a/src/types/Mappings.ts +++ b/src/types/Mappings.ts @@ -1,65 +1,3 @@ -import { JSONObject } from "./JSONObject"; - -type PropertyObject = { - properties?: MappingsProperties; -}; - -type PropertyDynamic = { - /** - * Dynamic mapping policy - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-dynamic-policy - */ - dynamic?: "true" | "false" | "strict"; -}; - -type PropertyType = { - [name: string]: { type?: string } | PropertyObject | JSONObject; -}; - -export type MappingsProperties = - | PropertyObject - | PropertyDynamic - | PropertyType; - -/** - * Collection mappings definition - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#collection-mappings - * - * @example - * ``` - * { - * properties: { - * name: { type: 'keyword' }, - * address: { - * properties: { - * zipcode: { type: 'integer' } - * } - * } - * } - * } - * ``` - */ -export type CollectionMappings = { - /** - * Collection metadata - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-metadata - */ - _meta?: JSONObject; - - /** - * Properties types definition - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-properties - */ - properties?: MappingsProperties; - - /** - * Dynamic mapping policy - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-dynamic-polic - */ - dynamic?: "true" | "false" | "strict"; -}; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { MappingsProperties, CollectionMappings } from "kuzzle-types"; diff --git a/src/types/Notification.ts b/src/types/Notification.ts index c45c6139..9dadffe6 100644 --- a/src/types/Notification.ts +++ b/src/types/Notification.ts @@ -1,125 +1,10 @@ -import { JSONObject } from "./JSONObject"; -import { KDocumentContentGeneric } from "."; - -/** - * Enum for notification types - */ -export type NotificationType = "document" | "user" | "TokenExpired"; - -export interface BaseNotification { - /** - * Notification type - */ - type: NotificationType; - - /** - * Controller that triggered the notification - */ - controller: string; - /** - * Action that triggered the notification - */ - action: string; - /** - * Event type according to API action - */ - event: "write" | "delete" | "publish"; - /** - * Index name - */ - index: string; - /** - * Collection name - */ - collection: string; - /** - * Network protocol used to trigger the notification - */ - protocol: string; - /** - * Subscription channel identifier. - * Can be used to link a notification to its corresponding subscription - */ - room: string; - /** - * Timestamp of the event, in Epoch-millis format - */ - timestamp: number; - /** - * Request volatile data - * @see https://docs.kuzzle.io/core/2/guides/essentials/volatile-data/ - */ - volatile: JSONObject; -} - -/** - * Notification triggered by a document change. - * (create, update, delete) - */ -export interface DocumentNotification< - TDocContent extends KDocumentContentGeneric = KDocumentContentGeneric, -> extends BaseNotification { - /** - * Updated document that triggered the notification - */ - result: { - /** - * The message or full document content. - */ - _source: TDocContent; - /** - * Document unique ID. - * `null` if the notification is from a real-time message. - */ - _id: string | null; - /** - * List of fields that have been updated (only available on document partial updates). - */ - _updatedFields?: string[]; - }; - /** - * State of the document regarding the scope (`in` or `out`) - */ - scope: "in" | "out"; - - type: "document"; -} - -/** - * Notification triggered by an user joining or leaving a subscription room - */ -export interface UserNotification extends BaseNotification { - /** - * Tell wether an user leave or join the subscription room (`in` or `out`) - */ - user: "in" | "out"; - - /** - * Contains the actual number of users in the subscription room - */ - result: { - /** - * Updated users count sharing the same subscription room - */ - count: number; - }; - - type: "user"; -} - -export interface ServerNotification extends BaseNotification { - /** - * Server message explaining why this notifications has been triggered. - */ - message: string; - - type: "TokenExpired"; -} - -/** - * Real-time notifications sent by Kuzzle. - */ -export type Notification = - | DocumentNotification - | UserNotification - | ServerNotification; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { + NotificationType, + BaseNotification, + DocumentNotification, + UserNotification, + ServerNotification, + Notification, +} from "kuzzle-types"; diff --git a/src/types/ProfilePolicy.ts b/src/types/ProfilePolicy.ts index 876cd643..211e39c0 100644 --- a/src/types/ProfilePolicy.ts +++ b/src/types/ProfilePolicy.ts @@ -1,42 +1,3 @@ -/** - * A profile policy is composed of a roleId to define API rights - * and an optional array of restrictions on index and collections - * - * @example - * { - * "roleId": "editor", - * "restrictedTo": { - * "index": "blog", - * "collections": [ - * "articles" - * ] - * } - * } - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/permissions/#policies - */ -export type ProfilePolicy = { - /** - * Role unique ID used by this policy - */ - roleId: string; - - /** - * Optional array of restrictions on which the rights are gonne be applied - */ - restrictedTo?: [ - { - /** - * Index name. - * Rights will only be applied on this index. - */ - index: string; - - /** - * Collection names. - * Rights will only be applied on those collections. - */ - collections?: Array; - }, - ]; -}; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { ProfilePolicy } from "kuzzle-types"; diff --git a/src/types/RequestPayload.ts b/src/types/RequestPayload.ts index 7efe9065..bc004db5 100644 --- a/src/types/RequestPayload.ts +++ b/src/types/RequestPayload.ts @@ -1,55 +1,3 @@ -import { JSONObject } from "./JSONObject"; - -/** - * Kuzzle API request payload - * - * @see https://docs.kuzzle.io/core/2/api/payloads/request - */ -export interface RequestPayload { - /** - * API controller name - */ - controller: string; - - /** - * API action name - */ - action: string; - - /** - * Index name - */ - index?: string; - - /** - * Collection name - */ - collection?: string; - - /** - * Document unique identifier - */ - _id?: string; - - /** - * Authentication token - */ - jwt?: string; - - /** - * Volatile data - */ - volatile?: JSONObject; - - /** - * Request body - */ - body?: JSONObject; - - /** - * Request unique identifier - */ - requestId?: string; - - [key: string]: any; -} +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { RequestPayload } from "kuzzle-types"; diff --git a/src/types/ResponsePayload.ts b/src/types/ResponsePayload.ts index f216fd48..7df186bf 100644 --- a/src/types/ResponsePayload.ts +++ b/src/types/ResponsePayload.ts @@ -1,103 +1,3 @@ -import { JSONObject } from "./JSONObject"; - -/** - * Kuzzle API response payload - * - * @see https://docs.kuzzle.io/core/2/api/payloads/response - */ -export interface ResponsePayload { - /** - * API controller name - */ - controller: string; - - /** - * API action name - */ - action: string; - - /** - * Index name - */ - index?: string; - - /** - * Collection name - */ - collection?: string; - - /** - * Document unique identifier - */ - _id?: string; - - /** - * Array of deprecation warnings (hidden if NODE_ENV=production) - */ - deprecations?: Array<{ - /** - * Deprecation description - */ - message: string; - - /** - * Deprecated since this version - */ - version: string; - }>; - - /** - * API error - */ - error?: { - /** - * Error human readable identifier - */ - id: string; - - /** - * Error identifier - */ - code: number; - - /** - * Error message - */ - message: string; - - /** - * HTTP status error code - */ - status: number; - - /** - * Error stacktrace (only if NODE_ENV=development) - */ - stack?: string; - }; - - /** - * Request unique identifier - */ - requestId: string; - - /** - * API action result - */ - result: TResult; - - /** - * HTTP status code - */ - status: number; - - /** - * Volatile data - */ - volatile?: JSONObject; - - /** - * Room unique identifier - */ - room?: string; -} +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { ResponsePayload } from "kuzzle-types"; diff --git a/src/types/RoleRightsDefinition.ts b/src/types/RoleRightsDefinition.ts index 7b46de6f..550bdd4b 100644 --- a/src/types/RoleRightsDefinition.ts +++ b/src/types/RoleRightsDefinition.ts @@ -1,36 +1,3 @@ -/** - * Role list of rights definition for controllers and actions. - * - * @example - * - * { - * auth: { - * actions: { - * getCurrentUser: true, - * getMyCredentials: true, - * getMyRights: true, - * logout: true - * } - * }, - * realtime: { - * actions: { - * "*": true - * } - * } - * } - * - * @see https://docs.kuzzle.io/core/2/guides/main-concepts/permissions/#roles - */ -export type RoleRightsDefinition = { - /** - * API controller name - */ - [controller: string]: { - actions: { - /** - * API action name - */ - [action: string]: boolean; - }; - }; -}; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { RoleRightsDefinition } from "kuzzle-types"; diff --git a/src/types/mRequests.ts b/src/types/mRequests.ts index ed21f3d9..0bf6edc2 100644 --- a/src/types/mRequests.ts +++ b/src/types/mRequests.ts @@ -1,53 +1,10 @@ -import { KDocumentContentGeneric } from "./KDocument"; - -export type mCreateRequest = - Array<{ - /** - * Document unique identifier - */ - _id?: string; - - /** - * Document content - */ - body: Partial; - }>; - -export type mCreateOrReplaceRequest< - TKDocumentContent extends KDocumentContentGeneric, -> = Array<{ - /** - * Document unique identifier - */ - _id: string; - - /** - * Document content - */ - body: Partial; -}>; - -export type mReplaceRequest = - mCreateOrReplaceRequest; -export type mUpdateRequest = - mCreateOrReplaceRequest; - -export type mUpsertRequest = - Array<{ - /** - * Document unique identifier - */ - _id: string; - - /** - * Document partial changes - */ - changes: Partial; - - /** - * Document fields to add to the "update" part if the document is created - */ - default?: Partial; - }>; - -export type mDeleteRequest = string[]; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { + mCreateRequest, + mCreateOrReplaceRequest, + mReplaceRequest, + mUpdateRequest, + mUpsertRequest, + mDeleteRequest, +} from "kuzzle-types"; diff --git a/src/types/mResponses.ts b/src/types/mResponses.ts index 3384bc98..cfa3acc1 100644 --- a/src/types/mResponses.ts +++ b/src/types/mResponses.ts @@ -1,104 +1,10 @@ -import { JSONObject } from "./JSONObject"; - -type mResponseErrors = Array<{ - /** - * Original document that caused the error - */ - document: { - _id: string; - body: JSONObject; - }; - - /** - * HTTP error status code - */ - status: number; - - /** - * Human readable reason - */ - reason: string; -}>; - -export type mCreateResponse = { - /** - * Array of succeeded operations - */ - successes: Array<{ - /** - * Document unique identifier - */ - _id: string; - - /** - * Document content - */ - _source: JSONObject; - - /** - * Document version number - */ - _version: number; - - /** - * `true` if document is created - */ - created: boolean; - }>; - - /** - * Arrays of errored operations - */ - errors: mResponseErrors; -}; - -export type mCreateOrReplaceResponse = mCreateResponse; -export type mUpsertResponse = mCreateResponse; - -export type mReplaceResponse = { - /** - * Array of succeeded operations - */ - successes: Array<{ - /** - * Document unique identifier - */ - _id: string; - - /** - * Document content - */ - _source: JSONObject; - - /** - * Document version number - */ - _version: number; - }>; - - /** - * Arrays of errored operations - */ - errors: mResponseErrors; -}; - -export type mUpdateResponse = mReplaceResponse; - -export type mDeleteResponse = { - /** - * IDs of deleted documents - */ - successes: string[]; - - errors: Array<{ - /** - * Document unique identifier - */ - _id: string; - - /** - * Human readable reason - */ - reason: string; - }>; -}; +// Moved to kuzzle-types, the API contract shared by kuzzle and kuzzle-sdk +// (Kuzzle ADR-0002 step 03). Kept so that imports of this path still work. +export type { + mCreateResponse, + mCreateOrReplaceResponse, + mUpsertResponse, + mReplaceResponse, + mUpdateResponse, + mDeleteResponse, +} from "kuzzle-types"; diff --git a/test/types/kuzzle-types.ts b/test/types/kuzzle-types.ts new file mode 100644 index 00000000..d95e3057 --- /dev/null +++ b/test/types/kuzzle-types.ts @@ -0,0 +1,87 @@ +// The API contract types moved to kuzzle-types (Kuzzle ADR-0002 step 03): the +// SDK must still export every one of them, under the same name, as exactly +// kuzzle-types' type — kuzzle-types itself asserts those are the types +// kuzzle-sdk 7.17.1 exported. `Document` is the exception: the SDK keeps its +// class, whose instances kuzzle-types' interface describes. +// Type-checked by `npm run test:types` (after `npm run build`); nothing here runs. +import type * as Types from "kuzzle-types"; + +// The built declarations — what users get — not the non-strict sources. +import type * as Sdk from "../../out"; + +/** `true` only if A and B are identical types (not merely assignable). */ +type Equals = + (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 + ? true + : false; + +/** Assignable both ways. */ +type Mutual = [A] extends [B] ? ([B] extends [A] ? true : false) : false; + +function assert(): T | void {} + +type Content = Types.KDocumentContent & { name: string }; + +// src/types/ApiKey.ts +assert>(); +// src/types/ArgsDefault.ts +assert>(); +// src/types/BaseRequest.ts +assert>(); +// src/types/Document.ts +assert>(); +assert>(); +// src/types/HttpRoutes.ts +assert>(); +// src/types/JSONObject.ts +assert>(); +// src/types/KDocument.ts +assert>(); +assert>(); +assert>(); +assert, Types.KDocument>>(); +assert, Types.KHit>>(); +// src/types/Mappings.ts +assert>(); +assert>(); +// src/types/Notification.ts +assert>(); +assert>(); +assert< + Equals, Types.DocumentNotification> +>(); +assert>(); +assert>(); +assert>(); +// src/types/ProfilePolicy.ts +assert>(); +// src/types/RequestPayload.ts +assert>(); +// src/types/ResponsePayload.ts +assert, Types.ResponsePayload>>(); +// src/types/RoleRightsDefinition.ts +assert>(); +// src/types/mRequests.ts +assert, Types.mCreateRequest>>(); +assert< + Equals< + Sdk.mCreateOrReplaceRequest, + Types.mCreateOrReplaceRequest + > +>(); +assert, Types.mReplaceRequest>>(); +assert, Types.mUpdateRequest>>(); +assert, Types.mUpsertRequest>>(); +assert>(); +// src/types/mResponses.ts +assert>(); +assert>(); +assert>(); +assert>(); +assert>(); +assert>(); + +// src/types/Document.ts — the class stays in the SDK, a runtime value. +assert>(); +assert>(); +export const document: typeof Sdk.Document = {} as typeof Sdk.Document; diff --git a/test/types/tsconfig.json b/test/types/tsconfig.json new file mode 100644 index 00000000..2986085b --- /dev/null +++ b/test/types/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "strict": true, + "skipLibCheck": true, + "noEmit": true + }, + "include": ["./**/*.ts"] +}