@ankhorage/contracts 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/data/diagnostics.d.ts +22 -0
- package/dist/data/diagnostics.d.ts.map +1 -0
- package/dist/data/diagnostics.js +2 -0
- package/dist/data/diagnostics.js.map +1 -0
- package/dist/data/endpoints.d.ts +18 -0
- package/dist/data/endpoints.d.ts.map +1 -0
- package/dist/data/endpoints.js +2 -0
- package/dist/data/endpoints.js.map +1 -0
- package/dist/data/ids.d.ts +7 -0
- package/dist/data/ids.d.ts.map +1 -0
- package/dist/data/ids.js +2 -0
- package/dist/data/ids.js.map +1 -0
- package/dist/data/index.d.ts +9 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +9 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/operations.d.ts +49 -0
- package/dist/data/operations.d.ts.map +1 -0
- package/dist/data/operations.js +2 -0
- package/dist/data/operations.js.map +1 -0
- package/dist/data/refs.d.ts +18 -0
- package/dist/data/refs.d.ts.map +1 -0
- package/dist/data/refs.js +2 -0
- package/dist/data/refs.js.map +1 -0
- package/dist/data/schemas.d.ts +34 -0
- package/dist/data/schemas.d.ts.map +1 -0
- package/dist/data/schemas.js +2 -0
- package/dist/data/schemas.js.map +1 -0
- package/dist/data/sources.d.ts +57 -0
- package/dist/data/sources.d.ts.map +1 -0
- package/dist/data/sources.js +2 -0
- package/dist/data/sources.js.map +1 -0
- package/dist/data/values.d.ts +5 -0
- package/dist/data/values.d.ts.map +1 -0
- package/dist/data/values.js +2 -0
- package/dist/data/values.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
- package/src/data/data.test.ts +305 -0
- package/src/data/diagnostics.ts +41 -0
- package/src/data/endpoints.ts +20 -0
- package/src/data/ids.ts +6 -0
- package/src/data/index.ts +8 -0
- package/src/data/operations.ts +66 -0
- package/src/data/refs.ts +21 -0
- package/src/data/schemas.ts +46 -0
- package/src/data/sources.ts +72 -0
- package/src/data/values.ts +11 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DataSourceId, EndpointId, OperationId } from './ids';
|
|
2
|
+
export type DataDiagnosticSeverity = 'error' | 'info' | 'warning';
|
|
3
|
+
export type DataDiagnosticCode = 'ambiguous-server' | 'duplicate-operation-id' | 'invalid-config' | 'missing-adapter' | 'missing-credential' | 'missing-data-source' | 'missing-endpoint' | 'missing-operation' | 'missing-schema' | 'network-error' | 'parse-error' | 'unsupported-auth-scheme' | 'unsupported-schema' | (string & {});
|
|
4
|
+
export interface DataSourceDiagnostic {
|
|
5
|
+
readonly code: DataDiagnosticCode;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly severity: DataDiagnosticSeverity;
|
|
8
|
+
readonly dataSourceId?: DataSourceId;
|
|
9
|
+
readonly endpointId?: EndpointId;
|
|
10
|
+
readonly operationId?: OperationId;
|
|
11
|
+
readonly path?: string;
|
|
12
|
+
readonly hint?: string;
|
|
13
|
+
}
|
|
14
|
+
export type DataSourceDiagnosticResult<TData> = {
|
|
15
|
+
readonly ok: true;
|
|
16
|
+
readonly data: TData;
|
|
17
|
+
readonly diagnostics?: readonly DataSourceDiagnostic[];
|
|
18
|
+
} | {
|
|
19
|
+
readonly ok: false;
|
|
20
|
+
readonly diagnostics: readonly DataSourceDiagnostic[];
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/data/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAElE,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,wBAAwB,GACxB,gBAAgB,GAChB,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,yBAAyB,GACzB,oBAAoB,GACpB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,0BAA0B,CAAC,KAAK,IACxC;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACxD,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,WAAW,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/data/diagnostics.ts"],"names":[],"mappings":"","sourcesContent":["import type { DataSourceId, EndpointId, OperationId } from './ids';\n\nexport type DataDiagnosticSeverity = 'error' | 'info' | 'warning';\n\nexport type DataDiagnosticCode =\n | 'ambiguous-server'\n | 'duplicate-operation-id'\n | 'invalid-config'\n | 'missing-adapter'\n | 'missing-credential'\n | 'missing-data-source'\n | 'missing-endpoint'\n | 'missing-operation'\n | 'missing-schema'\n | 'network-error'\n | 'parse-error'\n | 'unsupported-auth-scheme'\n | 'unsupported-schema'\n | (string & {});\n\nexport interface DataSourceDiagnostic {\n readonly code: DataDiagnosticCode;\n readonly message: string;\n readonly severity: DataDiagnosticSeverity;\n readonly dataSourceId?: DataSourceId;\n readonly endpointId?: EndpointId;\n readonly operationId?: OperationId;\n readonly path?: string;\n readonly hint?: string;\n}\n\nexport type DataSourceDiagnosticResult<TData> =\n | {\n readonly ok: true;\n readonly data: TData;\n readonly diagnostics?: readonly DataSourceDiagnostic[];\n }\n | {\n readonly ok: false;\n readonly diagnostics: readonly DataSourceDiagnostic[];\n };\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EndpointId, OperationId } from './ids';
|
|
2
|
+
import type { DataOperationConfig } from './operations';
|
|
3
|
+
import type { CredentialRef } from './refs';
|
|
4
|
+
import type { DataContractValue } from './values';
|
|
5
|
+
export type DataEndpointKind = 'database' | 'graphql' | 'http' | (string & {});
|
|
6
|
+
export interface DataEndpointConfig {
|
|
7
|
+
readonly id: EndpointId;
|
|
8
|
+
readonly kind: DataEndpointKind;
|
|
9
|
+
readonly name?: string;
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
readonly baseUrl?: string;
|
|
12
|
+
readonly path?: string;
|
|
13
|
+
readonly credential?: CredentialRef;
|
|
14
|
+
readonly operations: Readonly<Record<OperationId, DataOperationConfig>>;
|
|
15
|
+
readonly metadata?: DataContractValue;
|
|
16
|
+
}
|
|
17
|
+
export type DataEndpointRegistry = Readonly<Record<EndpointId, DataEndpointConfig>>;
|
|
18
|
+
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/data/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE/E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../src/data/endpoints.ts"],"names":[],"mappings":"","sourcesContent":["import type { EndpointId, OperationId } from './ids';\nimport type { DataOperationConfig } from './operations';\nimport type { CredentialRef } from './refs';\nimport type { DataContractValue } from './values';\n\nexport type DataEndpointKind = 'database' | 'graphql' | 'http' | (string & {});\n\nexport interface DataEndpointConfig {\n readonly id: EndpointId;\n readonly kind: DataEndpointKind;\n readonly name?: string;\n readonly description?: string;\n readonly baseUrl?: string;\n readonly path?: string;\n readonly credential?: CredentialRef;\n readonly operations: Readonly<Record<OperationId, DataOperationConfig>>;\n readonly metadata?: DataContractValue;\n}\n\nexport type DataEndpointRegistry = Readonly<Record<EndpointId, DataEndpointConfig>>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/data/ids.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC"}
|
package/dist/data/ids.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/data/ids.ts"],"names":[],"mappings":"","sourcesContent":["export type DataSourceId = string;\nexport type EndpointId = string;\nexport type OperationId = string;\nexport type SchemaId = string;\nexport type CredentialId = string;\nexport type AdapterId = string;\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './diagnostics';
|
|
2
|
+
export * from './endpoints';
|
|
3
|
+
export * from './ids';
|
|
4
|
+
export * from './operations';
|
|
5
|
+
export * from './refs';
|
|
6
|
+
export * from './schemas';
|
|
7
|
+
export * from './sources';
|
|
8
|
+
export * from './values';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './diagnostics';
|
|
2
|
+
export * from './endpoints';
|
|
3
|
+
export * from './ids';
|
|
4
|
+
export * from './operations';
|
|
5
|
+
export * from './refs';
|
|
6
|
+
export * from './schemas';
|
|
7
|
+
export * from './sources';
|
|
8
|
+
export * from './values';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC","sourcesContent":["export * from './diagnostics';\nexport * from './endpoints';\nexport * from './ids';\nexport * from './operations';\nexport * from './refs';\nexport * from './schemas';\nexport * from './sources';\nexport * from './values';\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EndpointId, OperationId } from './ids';
|
|
2
|
+
import type { CredentialRef } from './refs';
|
|
3
|
+
import type { DataSchemaSlot } from './schemas';
|
|
4
|
+
import type { DataContractValue } from './values';
|
|
5
|
+
export type DataOperationIntent = 'action' | 'create' | 'delete' | 'read' | 'update';
|
|
6
|
+
export type DataOperationMethod = 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | (string & {});
|
|
7
|
+
export type DataOperationProtocol = 'database' | 'graphql' | 'http' | (string & {});
|
|
8
|
+
export type DataOperationParameterLocation = 'body' | 'cookie' | 'header' | 'path' | 'query';
|
|
9
|
+
export interface DataOperationParameter extends DataSchemaSlot {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly location: DataOperationParameterLocation;
|
|
12
|
+
readonly required?: boolean;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
readonly default?: DataContractValue;
|
|
15
|
+
}
|
|
16
|
+
export interface DataOperationRequest extends DataSchemaSlot {
|
|
17
|
+
readonly parameters?: readonly DataOperationParameter[];
|
|
18
|
+
readonly contentType?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DataOperationResponse extends DataSchemaSlot {
|
|
21
|
+
readonly status?: number | string;
|
|
22
|
+
readonly contentType?: string;
|
|
23
|
+
readonly description?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DataOperationPagination {
|
|
26
|
+
readonly kind: 'cursor' | 'limit-offset' | 'page' | 'unknown' | (string & {});
|
|
27
|
+
readonly cursorPath?: string;
|
|
28
|
+
readonly limitParameter?: string;
|
|
29
|
+
readonly offsetParameter?: string;
|
|
30
|
+
readonly pageParameter?: string;
|
|
31
|
+
readonly pageSizeParameter?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface DataOperationConfig {
|
|
34
|
+
readonly id: OperationId;
|
|
35
|
+
readonly endpointId?: EndpointId;
|
|
36
|
+
readonly name?: string;
|
|
37
|
+
readonly description?: string;
|
|
38
|
+
readonly protocol: DataOperationProtocol;
|
|
39
|
+
readonly intent: DataOperationIntent;
|
|
40
|
+
readonly method?: DataOperationMethod;
|
|
41
|
+
readonly path?: string;
|
|
42
|
+
readonly request?: DataOperationRequest;
|
|
43
|
+
readonly response?: DataOperationResponse;
|
|
44
|
+
readonly pagination?: DataOperationPagination;
|
|
45
|
+
readonly credential?: CredentialRef;
|
|
46
|
+
readonly metadata?: DataContractValue;
|
|
47
|
+
}
|
|
48
|
+
export type DataOperationRegistry = Readonly<Record<OperationId, DataOperationConfig>>;
|
|
49
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
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AAC,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/data/operations.ts"],"names":[],"mappings":"","sourcesContent":["import type { EndpointId, OperationId } from './ids';\nimport type { CredentialRef } from './refs';\nimport type { DataSchemaSlot } from './schemas';\nimport type { DataContractValue } from './values';\n\nexport type DataOperationIntent = 'action' | 'create' | 'delete' | 'read' | 'update';\n\nexport type DataOperationMethod =\n | 'DELETE'\n | 'GET'\n | 'HEAD'\n | 'OPTIONS'\n | 'PATCH'\n | 'POST'\n | 'PUT'\n | (string & {});\n\nexport type DataOperationProtocol = 'database' | 'graphql' | 'http' | (string & {});\n\nexport type DataOperationParameterLocation = 'body' | 'cookie' | 'header' | 'path' | 'query';\n\nexport interface DataOperationParameter extends DataSchemaSlot {\n readonly name: string;\n readonly location: DataOperationParameterLocation;\n readonly required?: boolean;\n readonly description?: string;\n readonly default?: DataContractValue;\n}\n\nexport interface DataOperationRequest extends DataSchemaSlot {\n readonly parameters?: readonly DataOperationParameter[];\n readonly contentType?: string;\n}\n\nexport interface DataOperationResponse extends DataSchemaSlot {\n readonly status?: number | string;\n readonly contentType?: string;\n readonly description?: string;\n}\n\nexport interface DataOperationPagination {\n readonly kind: 'cursor' | 'limit-offset' | 'page' | 'unknown' | (string & {});\n readonly cursorPath?: string;\n readonly limitParameter?: string;\n readonly offsetParameter?: string;\n readonly pageParameter?: string;\n readonly pageSizeParameter?: string;\n}\n\nexport interface DataOperationConfig {\n readonly id: OperationId;\n readonly endpointId?: EndpointId;\n readonly name?: string;\n readonly description?: string;\n readonly protocol: DataOperationProtocol;\n readonly intent: DataOperationIntent;\n readonly method?: DataOperationMethod;\n readonly path?: string;\n readonly request?: DataOperationRequest;\n readonly response?: DataOperationResponse;\n readonly pagination?: DataOperationPagination;\n readonly credential?: CredentialRef;\n readonly metadata?: DataContractValue;\n}\n\nexport type DataOperationRegistry = Readonly<Record<OperationId, DataOperationConfig>>;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AdapterId, CredentialId } from './ids';
|
|
2
|
+
import type { DataContractValue } from './values';
|
|
3
|
+
export type CredentialKind = 'apiKey' | 'basic' | 'bearer' | 'custom' | 'oauth2';
|
|
4
|
+
export interface CredentialRef {
|
|
5
|
+
readonly id: CredentialId;
|
|
6
|
+
readonly kind: CredentialKind | (string & {});
|
|
7
|
+
readonly label?: string;
|
|
8
|
+
readonly scope?: string;
|
|
9
|
+
}
|
|
10
|
+
export type AdapterKind = 'auth' | 'database' | 'storage' | 'transport' | (string & {});
|
|
11
|
+
export interface AdapterRef {
|
|
12
|
+
readonly id: AdapterId;
|
|
13
|
+
readonly kind: AdapterKind;
|
|
14
|
+
readonly packageName?: string;
|
|
15
|
+
readonly exportName?: string;
|
|
16
|
+
readonly config?: DataContractValue;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/data/refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAExF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/data/refs.ts"],"names":[],"mappings":"","sourcesContent":["import type { AdapterId, CredentialId } from './ids';\nimport type { DataContractValue } from './values';\n\nexport type CredentialKind = 'apiKey' | 'basic' | 'bearer' | 'custom' | 'oauth2';\n\nexport interface CredentialRef {\n readonly id: CredentialId;\n readonly kind: CredentialKind | (string & {});\n readonly label?: string;\n readonly scope?: string;\n}\n\nexport type AdapterKind = 'auth' | 'database' | 'storage' | 'transport' | (string & {});\n\nexport interface AdapterRef {\n readonly id: AdapterId;\n readonly kind: AdapterKind;\n readonly packageName?: string;\n readonly exportName?: string;\n readonly config?: DataContractValue;\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SchemaId } from './ids';
|
|
2
|
+
import type { DataContractValue } from './values';
|
|
3
|
+
export type DataSchemaPrimitiveType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
|
|
4
|
+
export interface DataSchemaRef {
|
|
5
|
+
readonly id: SchemaId;
|
|
6
|
+
}
|
|
7
|
+
export interface DataSchemaProperty {
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
readonly schema: DataSchema;
|
|
10
|
+
}
|
|
11
|
+
export interface DataSchema {
|
|
12
|
+
readonly type?: DataSchemaPrimitiveType | readonly DataSchemaPrimitiveType[];
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
readonly enum?: readonly DataContractValue[];
|
|
16
|
+
readonly const?: DataContractValue;
|
|
17
|
+
readonly default?: DataContractValue;
|
|
18
|
+
readonly format?: string;
|
|
19
|
+
readonly nullable?: boolean;
|
|
20
|
+
readonly required?: readonly string[];
|
|
21
|
+
readonly properties?: Readonly<Record<string, DataSchema>>;
|
|
22
|
+
readonly additionalProperties?: boolean | DataSchema;
|
|
23
|
+
readonly items?: DataSchema;
|
|
24
|
+
readonly allOf?: readonly DataSchema[];
|
|
25
|
+
readonly anyOf?: readonly DataSchema[];
|
|
26
|
+
readonly oneOf?: readonly DataSchema[];
|
|
27
|
+
readonly ref?: DataSchemaRef;
|
|
28
|
+
}
|
|
29
|
+
export type DataSchemaRegistry = Readonly<Record<SchemaId, DataSchema>>;
|
|
30
|
+
export interface DataSchemaSlot {
|
|
31
|
+
readonly schema?: DataSchema;
|
|
32
|
+
readonly schemaRef?: DataSchemaRef;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/data/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,MAAM,uBAAuB,GAC/B,OAAO,GACP,SAAS,GACT,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,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,aAAa,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/data/schemas.ts"],"names":[],"mappings":"","sourcesContent":["import type { SchemaId } from './ids';\nimport type { DataContractValue } from './values';\n\nexport type DataSchemaPrimitiveType =\n | 'array'\n | 'boolean'\n | 'integer'\n | 'null'\n | 'number'\n | 'object'\n | 'string';\n\nexport interface DataSchemaRef {\n readonly id: SchemaId;\n}\n\nexport interface DataSchemaProperty {\n readonly description?: string;\n readonly schema: DataSchema;\n}\n\nexport interface DataSchema {\n readonly type?: DataSchemaPrimitiveType | readonly DataSchemaPrimitiveType[];\n readonly title?: string;\n readonly description?: string;\n readonly enum?: readonly DataContractValue[];\n readonly const?: DataContractValue;\n readonly default?: DataContractValue;\n readonly format?: string;\n readonly nullable?: boolean;\n readonly required?: readonly string[];\n readonly properties?: Readonly<Record<string, DataSchema>>;\n readonly additionalProperties?: boolean | DataSchema;\n readonly items?: DataSchema;\n readonly allOf?: readonly DataSchema[];\n readonly anyOf?: readonly DataSchema[];\n readonly oneOf?: readonly DataSchema[];\n readonly ref?: DataSchemaRef;\n}\n\nexport type DataSchemaRegistry = Readonly<Record<SchemaId, DataSchema>>;\n\nexport interface DataSchemaSlot {\n readonly schema?: DataSchema;\n readonly schemaRef?: DataSchemaRef;\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DbCollectionDefinition } from '../db';
|
|
2
|
+
import type { DataEndpointRegistry } from './endpoints';
|
|
3
|
+
import type { DataSourceId } from './ids';
|
|
4
|
+
import type { AdapterRef, CredentialRef } from './refs';
|
|
5
|
+
import type { DataSchemaRegistry } from './schemas';
|
|
6
|
+
import type { DataContractValue } from './values';
|
|
7
|
+
export type DataSourceKind = 'database' | 'graphql' | 'managed-api' | 'openapi' | 'rest';
|
|
8
|
+
export interface DataSourceBaseConfig {
|
|
9
|
+
readonly id: DataSourceId;
|
|
10
|
+
readonly kind: DataSourceKind;
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly credential?: CredentialRef;
|
|
14
|
+
readonly endpoints: DataEndpointRegistry;
|
|
15
|
+
readonly schemas?: DataSchemaRegistry;
|
|
16
|
+
readonly metadata?: DataContractValue;
|
|
17
|
+
}
|
|
18
|
+
export interface RestDataSourceConfig extends DataSourceBaseConfig {
|
|
19
|
+
readonly kind: 'rest';
|
|
20
|
+
readonly baseUrl: string;
|
|
21
|
+
}
|
|
22
|
+
export interface OpenApiImportRef {
|
|
23
|
+
readonly url?: string;
|
|
24
|
+
readonly documentId?: string;
|
|
25
|
+
readonly version?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface OpenApiDataSourceConfig extends DataSourceBaseConfig {
|
|
28
|
+
readonly kind: 'openapi';
|
|
29
|
+
readonly baseUrl?: string;
|
|
30
|
+
readonly import?: OpenApiImportRef;
|
|
31
|
+
}
|
|
32
|
+
export interface GraphQlDataSourceConfig extends DataSourceBaseConfig {
|
|
33
|
+
readonly kind: 'graphql';
|
|
34
|
+
readonly endpointUrl: string;
|
|
35
|
+
readonly introspection?: {
|
|
36
|
+
readonly enabled: boolean;
|
|
37
|
+
readonly schemaVersion?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface DatabaseDataSourceConfig extends DataSourceBaseConfig {
|
|
41
|
+
readonly kind: 'database';
|
|
42
|
+
readonly adapter: AdapterRef;
|
|
43
|
+
}
|
|
44
|
+
export interface ManagedApiResourceConfig {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly collection: DbCollectionDefinition;
|
|
47
|
+
readonly operations?: readonly ('create' | 'delete' | 'list' | 'read' | 'update')[];
|
|
48
|
+
readonly metadata?: DataContractValue;
|
|
49
|
+
}
|
|
50
|
+
export interface ManagedApiDataSourceConfig extends DataSourceBaseConfig {
|
|
51
|
+
readonly kind: 'managed-api';
|
|
52
|
+
readonly adapter: AdapterRef;
|
|
53
|
+
readonly resources: readonly ManagedApiResourceConfig[];
|
|
54
|
+
}
|
|
55
|
+
export type DataSourceConfig = DatabaseDataSourceConfig | GraphQlDataSourceConfig | ManagedApiDataSourceConfig | OpenApiDataSourceConfig | RestDataSourceConfig;
|
|
56
|
+
export type DataSourceRegistry = Readonly<Record<DataSourceId, DataSourceConfig>>;
|
|
57
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/data/sources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,WAAW,oBAAqB,S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AoB;IACtE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,wBAAwB,EAAE,CAAC;CACzD;AAED,MAAM,MAAM,gBAAgB,GACxB,wBAAwB,GACxB,uBAAuB,GACvB,0BAA0B,GAC1B,uBAAuB,GACvB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../src/data/sources.ts"],"names":[],"mappings":"","sourcesContent":["import type { DbCollectionDefinition } from '../db';\nimport type { DataEndpointRegistry } from './endpoints';\nimport type { DataSourceId } from './ids';\nimport type { AdapterRef, CredentialRef } from './refs';\nimport type { DataSchemaRegistry } from './schemas';\nimport type { DataContractValue } from './values';\n\nexport type DataSourceKind = 'database' | 'graphql' | 'managed-api' | 'openapi' | 'rest';\n\nexport interface DataSourceBaseConfig {\n readonly id: DataSourceId;\n readonly kind: DataSourceKind;\n readonly name?: string;\n readonly description?: string;\n readonly credential?: CredentialRef;\n readonly endpoints: DataEndpointRegistry;\n readonly schemas?: DataSchemaRegistry;\n readonly metadata?: DataContractValue;\n}\n\nexport interface RestDataSourceConfig extends DataSourceBaseConfig {\n readonly kind: 'rest';\n readonly baseUrl: string;\n}\n\nexport interface OpenApiImportRef {\n readonly url?: string;\n readonly documentId?: string;\n readonly version?: string;\n}\n\nexport interface OpenApiDataSourceConfig extends DataSourceBaseConfig {\n readonly kind: 'openapi';\n readonly baseUrl?: string;\n readonly import?: OpenApiImportRef;\n}\n\nexport interface GraphQlDataSourceConfig extends DataSourceBaseConfig {\n readonly kind: 'graphql';\n readonly endpointUrl: string;\n readonly introspection?: {\n readonly enabled: boolean;\n readonly schemaVersion?: string;\n };\n}\n\nexport interface DatabaseDataSourceConfig extends DataSourceBaseConfig {\n readonly kind: 'database';\n readonly adapter: AdapterRef;\n}\n\nexport interface ManagedApiResourceConfig {\n readonly name: string;\n readonly collection: DbCollectionDefinition;\n readonly operations?: readonly ('create' | 'delete' | 'list' | 'read' | 'update')[];\n readonly metadata?: DataContractValue;\n}\n\nexport interface ManagedApiDataSourceConfig extends DataSourceBaseConfig {\n readonly kind: 'managed-api';\n readonly adapter: AdapterRef;\n readonly resources: readonly ManagedApiResourceConfig[];\n}\n\nexport type DataSourceConfig =\n | DatabaseDataSourceConfig\n | GraphQlDataSourceConfig\n | ManagedApiDataSourceConfig\n | OpenApiDataSourceConfig\n | RestDataSourceConfig;\n\nexport type DataSourceRegistry = Readonly<Record<DataSourceId, DataSourceConfig>>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/data/values.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,iBAAiB,EAAE,GAC5B;IACE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAC3C,CAAC;AAEN,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/data/values.ts"],"names":[],"mappings":"","sourcesContent":["export type DataContractValue =\n | string\n | number\n | boolean\n | null\n | readonly DataContractValue[]\n | {\n readonly [key: string]: DataContractValue;\n };\n\nexport type DataPath = string;\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC","sourcesContent":["export * from './auth';\nexport * from './bindings';\nexport * from './db';\nexport * from './state';\nexport * from './storage';\nexport * from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC","sourcesContent":["export * from './auth';\nexport * from './bindings';\nexport * from './data';\nexport * from './db';\nexport * from './state';\nexport * from './storage';\nexport * from './types';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/contracts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@ankhorage/color-theory": "^0.0.7"
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"types": "./dist/bindings.d.ts",
|
|
26
26
|
"default": "./dist/bindings.js"
|
|
27
27
|
},
|
|
28
|
+
"./data": {
|
|
29
|
+
"types": "./dist/data/index.d.ts",
|
|
30
|
+
"default": "./dist/data/index.js"
|
|
31
|
+
},
|
|
28
32
|
"./db": {
|
|
29
33
|
"types": "./dist/db.d.ts",
|
|
30
34
|
"default": "./dist/db.js"
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
DataSourceConfig,
|
|
5
|
+
DataSourceDiagnostic,
|
|
6
|
+
GraphQlDataSourceConfig,
|
|
7
|
+
ManagedApiDataSourceConfig,
|
|
8
|
+
OpenApiDataSourceConfig,
|
|
9
|
+
RestDataSourceConfig,
|
|
10
|
+
} from './index';
|
|
11
|
+
|
|
12
|
+
function assertSerializable<TValue>(value: TValue): void {
|
|
13
|
+
expect(JSON.parse(JSON.stringify(value))).toEqual(value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('data source contracts', () => {
|
|
17
|
+
it('serializes a manual REST data source with read and create operations', () => {
|
|
18
|
+
const source: RestDataSourceConfig = {
|
|
19
|
+
id: 'cms-rest',
|
|
20
|
+
kind: 'rest',
|
|
21
|
+
name: 'CMS REST API',
|
|
22
|
+
baseUrl: 'https://cms.example.com',
|
|
23
|
+
credential: {
|
|
24
|
+
id: 'cms-api-key',
|
|
25
|
+
kind: 'apiKey',
|
|
26
|
+
label: 'CMS API key',
|
|
27
|
+
},
|
|
28
|
+
schemas: {
|
|
29
|
+
post: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
required: ['id', 'title'],
|
|
32
|
+
properties: {
|
|
33
|
+
id: { type: 'string' },
|
|
34
|
+
title: { type: 'string' },
|
|
35
|
+
published: { type: 'boolean', default: false },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
endpoints: {
|
|
40
|
+
posts: {
|
|
41
|
+
id: 'posts',
|
|
42
|
+
kind: 'http',
|
|
43
|
+
path: '/posts',
|
|
44
|
+
operations: {
|
|
45
|
+
'posts.list': {
|
|
46
|
+
id: 'posts.list',
|
|
47
|
+
endpointId: 'posts',
|
|
48
|
+
protocol: 'http',
|
|
49
|
+
intent: 'read',
|
|
50
|
+
method: 'GET',
|
|
51
|
+
path: '/posts',
|
|
52
|
+
request: {
|
|
53
|
+
parameters: [
|
|
54
|
+
{
|
|
55
|
+
name: 'limit',
|
|
56
|
+
location: 'query',
|
|
57
|
+
schema: { type: 'integer', default: 20 },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
response: {
|
|
62
|
+
status: 200,
|
|
63
|
+
schema: {
|
|
64
|
+
type: 'array',
|
|
65
|
+
items: { ref: { id: 'post' } },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
pagination: {
|
|
69
|
+
kind: 'limit-offset',
|
|
70
|
+
limitParameter: 'limit',
|
|
71
|
+
offsetParameter: 'offset',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
'posts.create': {
|
|
75
|
+
id: 'posts.create',
|
|
76
|
+
endpointId: 'posts',
|
|
77
|
+
protocol: 'http',
|
|
78
|
+
intent: 'create',
|
|
79
|
+
method: 'POST',
|
|
80
|
+
path: '/posts',
|
|
81
|
+
request: {
|
|
82
|
+
contentType: 'application/json',
|
|
83
|
+
schema: { ref: { id: 'post' } },
|
|
84
|
+
},
|
|
85
|
+
response: {
|
|
86
|
+
status: 201,
|
|
87
|
+
schemaRef: { id: 'post' },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
assertSerializable(source);
|
|
96
|
+
expect(source.endpoints.posts?.operations['posts.list']?.intent).toBe('read');
|
|
97
|
+
expect(source.endpoints.posts?.operations['posts.create']?.intent).toBe('create');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('serializes an imported OpenAPI data source', () => {
|
|
101
|
+
const source: OpenApiDataSourceConfig = {
|
|
102
|
+
id: 'shop-openapi',
|
|
103
|
+
kind: 'openapi',
|
|
104
|
+
name: 'Shop OpenAPI',
|
|
105
|
+
baseUrl: 'https://shop.example.com/api',
|
|
106
|
+
import: {
|
|
107
|
+
url: 'https://shop.example.com/openapi.json',
|
|
108
|
+
version: '2026-05-19',
|
|
109
|
+
},
|
|
110
|
+
endpoints: {
|
|
111
|
+
products: {
|
|
112
|
+
id: 'products',
|
|
113
|
+
kind: 'http',
|
|
114
|
+
path: '/products/{productId}',
|
|
115
|
+
operations: {
|
|
116
|
+
getProduct: {
|
|
117
|
+
id: 'getProduct',
|
|
118
|
+
endpointId: 'products',
|
|
119
|
+
protocol: 'http',
|
|
120
|
+
intent: 'read',
|
|
121
|
+
method: 'GET',
|
|
122
|
+
path: '/products/{productId}',
|
|
123
|
+
request: {
|
|
124
|
+
parameters: [
|
|
125
|
+
{
|
|
126
|
+
name: 'productId',
|
|
127
|
+
location: 'path',
|
|
128
|
+
required: true,
|
|
129
|
+
schema: { type: 'string' },
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
response: {
|
|
134
|
+
status: 200,
|
|
135
|
+
schema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {
|
|
138
|
+
id: { type: 'string' },
|
|
139
|
+
name: { type: 'string' },
|
|
140
|
+
price: { type: 'number' },
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
assertSerializable(source);
|
|
151
|
+
expect(source.import?.url).toContain('openapi.json');
|
|
152
|
+
expect(
|
|
153
|
+
source.endpoints.products?.operations.getProduct?.request?.parameters?.[0]?.location,
|
|
154
|
+
).toBe('path');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('serializes a GraphQL data source with query and mutation operations', () => {
|
|
158
|
+
const source: GraphQlDataSourceConfig = {
|
|
159
|
+
id: 'content-graphql',
|
|
160
|
+
kind: 'graphql',
|
|
161
|
+
endpointUrl: 'https://content.example.com/graphql',
|
|
162
|
+
introspection: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
schemaVersion: '2026-05-19',
|
|
165
|
+
},
|
|
166
|
+
endpoints: {
|
|
167
|
+
graphql: {
|
|
168
|
+
id: 'graphql',
|
|
169
|
+
kind: 'graphql',
|
|
170
|
+
operations: {
|
|
171
|
+
PostsQuery: {
|
|
172
|
+
id: 'PostsQuery',
|
|
173
|
+
endpointId: 'graphql',
|
|
174
|
+
protocol: 'graphql',
|
|
175
|
+
intent: 'read',
|
|
176
|
+
request: {
|
|
177
|
+
schema: {
|
|
178
|
+
type: 'object',
|
|
179
|
+
properties: {
|
|
180
|
+
search: { type: 'string' },
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
response: {
|
|
185
|
+
schema: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: {
|
|
188
|
+
posts: {
|
|
189
|
+
type: 'array',
|
|
190
|
+
items: { type: 'object' },
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
CreatePost: {
|
|
197
|
+
id: 'CreatePost',
|
|
198
|
+
endpointId: 'graphql',
|
|
199
|
+
protocol: 'graphql',
|
|
200
|
+
intent: 'create',
|
|
201
|
+
request: {
|
|
202
|
+
schema: {
|
|
203
|
+
type: 'object',
|
|
204
|
+
required: ['title'],
|
|
205
|
+
properties: {
|
|
206
|
+
title: { type: 'string' },
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
response: {
|
|
211
|
+
schema: {
|
|
212
|
+
type: 'object',
|
|
213
|
+
properties: {
|
|
214
|
+
createPost: { type: 'object' },
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
assertSerializable(source);
|
|
225
|
+
expect(source.endpoints.graphql?.operations.PostsQuery?.protocol).toBe('graphql');
|
|
226
|
+
expect(source.endpoints.graphql?.operations.CreatePost?.intent).toBe('create');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('serializes a managed API backed by a database adapter reference', () => {
|
|
230
|
+
const source: ManagedApiDataSourceConfig = {
|
|
231
|
+
id: 'app-managed-api',
|
|
232
|
+
kind: 'managed-api',
|
|
233
|
+
name: 'App managed API',
|
|
234
|
+
adapter: {
|
|
235
|
+
id: 'primary-db',
|
|
236
|
+
kind: 'database',
|
|
237
|
+
packageName: '@ankhorage/supabase-db',
|
|
238
|
+
},
|
|
239
|
+
resources: [
|
|
240
|
+
{
|
|
241
|
+
name: 'posts',
|
|
242
|
+
collection: {
|
|
243
|
+
name: 'posts',
|
|
244
|
+
schema: 'public',
|
|
245
|
+
primaryKey: 'id',
|
|
246
|
+
fields: [
|
|
247
|
+
{ name: 'id', type: 'uuid', required: true, unique: true },
|
|
248
|
+
{ name: 'title', type: 'text', required: true },
|
|
249
|
+
{ name: 'published', type: 'boolean', defaultValue: false },
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
operations: ['list', 'read', 'create', 'update', 'delete'],
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
endpoints: {
|
|
256
|
+
posts: {
|
|
257
|
+
id: 'posts',
|
|
258
|
+
kind: 'database',
|
|
259
|
+
operations: {
|
|
260
|
+
'posts.list': {
|
|
261
|
+
id: 'posts.list',
|
|
262
|
+
endpointId: 'posts',
|
|
263
|
+
protocol: 'database',
|
|
264
|
+
intent: 'read',
|
|
265
|
+
},
|
|
266
|
+
'posts.delete': {
|
|
267
|
+
id: 'posts.delete',
|
|
268
|
+
endpointId: 'posts',
|
|
269
|
+
protocol: 'database',
|
|
270
|
+
intent: 'delete',
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
assertSerializable(source);
|
|
278
|
+
expect(source.adapter.kind).toBe('database');
|
|
279
|
+
expect(source.resources[0]?.collection.fields.map((field) => field.name)).toEqual([
|
|
280
|
+
'id',
|
|
281
|
+
'title',
|
|
282
|
+
'published',
|
|
283
|
+
]);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('accepts a provider-neutral data source registry and diagnostics', () => {
|
|
287
|
+
const source: DataSourceConfig = {
|
|
288
|
+
id: 'public-rest',
|
|
289
|
+
kind: 'rest',
|
|
290
|
+
baseUrl: 'https://public.example.com',
|
|
291
|
+
endpoints: {},
|
|
292
|
+
};
|
|
293
|
+
const diagnostic: DataSourceDiagnostic = {
|
|
294
|
+
code: 'missing-operation',
|
|
295
|
+
severity: 'error',
|
|
296
|
+
message: 'Operation not found.',
|
|
297
|
+
dataSourceId: 'public-rest',
|
|
298
|
+
endpointId: 'posts',
|
|
299
|
+
operationId: 'posts.list',
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
assertSerializable({ source, diagnostic });
|
|
303
|
+
expect(diagnostic.code).toBe('missing-operation');
|
|
304
|
+
});
|
|
305
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DataSourceId, EndpointId, OperationId } from './ids';
|
|
2
|
+
|
|
3
|
+
export type DataDiagnosticSeverity = 'error' | 'info' | 'warning';
|
|
4
|
+
|
|
5
|
+
export type DataDiagnosticCode =
|
|
6
|
+
| 'ambiguous-server'
|
|
7
|
+
| 'duplicate-operation-id'
|
|
8
|
+
| 'invalid-config'
|
|
9
|
+
| 'missing-adapter'
|
|
10
|
+
| 'missing-credential'
|
|
11
|
+
| 'missing-data-source'
|
|
12
|
+
| 'missing-endpoint'
|
|
13
|
+
| 'missing-operation'
|
|
14
|
+
| 'missing-schema'
|
|
15
|
+
| 'network-error'
|
|
16
|
+
| 'parse-error'
|
|
17
|
+
| 'unsupported-auth-scheme'
|
|
18
|
+
| 'unsupported-schema'
|
|
19
|
+
| (string & {});
|
|
20
|
+
|
|
21
|
+
export interface DataSourceDiagnostic {
|
|
22
|
+
readonly code: DataDiagnosticCode;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly severity: DataDiagnosticSeverity;
|
|
25
|
+
readonly dataSourceId?: DataSourceId;
|
|
26
|
+
readonly endpointId?: EndpointId;
|
|
27
|
+
readonly operationId?: OperationId;
|
|
28
|
+
readonly path?: string;
|
|
29
|
+
readonly hint?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type DataSourceDiagnosticResult<TData> =
|
|
33
|
+
| {
|
|
34
|
+
readonly ok: true;
|
|
35
|
+
readonly data: TData;
|
|
36
|
+
readonly diagnostics?: readonly DataSourceDiagnostic[];
|
|
37
|
+
}
|
|
38
|
+
| {
|
|
39
|
+
readonly ok: false;
|
|
40
|
+
readonly diagnostics: readonly DataSourceDiagnostic[];
|
|
41
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EndpointId, OperationId } from './ids';
|
|
2
|
+
import type { DataOperationConfig } from './operations';
|
|
3
|
+
import type { CredentialRef } from './refs';
|
|
4
|
+
import type { DataContractValue } from './values';
|
|
5
|
+
|
|
6
|
+
export type DataEndpointKind = 'database' | 'graphql' | 'http' | (string & {});
|
|
7
|
+
|
|
8
|
+
export interface DataEndpointConfig {
|
|
9
|
+
readonly id: EndpointId;
|
|
10
|
+
readonly kind: DataEndpointKind;
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly baseUrl?: string;
|
|
14
|
+
readonly path?: string;
|
|
15
|
+
readonly credential?: CredentialRef;
|
|
16
|
+
readonly operations: Readonly<Record<OperationId, DataOperationConfig>>;
|
|
17
|
+
readonly metadata?: DataContractValue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type DataEndpointRegistry = Readonly<Record<EndpointId, DataEndpointConfig>>;
|
package/src/data/ids.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { EndpointId, OperationId } from './ids';
|
|
2
|
+
import type { CredentialRef } from './refs';
|
|
3
|
+
import type { DataSchemaSlot } from './schemas';
|
|
4
|
+
import type { DataContractValue } from './values';
|
|
5
|
+
|
|
6
|
+
export type DataOperationIntent = 'action' | 'create' | 'delete' | 'read' | 'update';
|
|
7
|
+
|
|
8
|
+
export type DataOperationMethod =
|
|
9
|
+
| 'DELETE'
|
|
10
|
+
| 'GET'
|
|
11
|
+
| 'HEAD'
|
|
12
|
+
| 'OPTIONS'
|
|
13
|
+
| 'PATCH'
|
|
14
|
+
| 'POST'
|
|
15
|
+
| 'PUT'
|
|
16
|
+
| (string & {});
|
|
17
|
+
|
|
18
|
+
export type DataOperationProtocol = 'database' | 'graphql' | 'http' | (string & {});
|
|
19
|
+
|
|
20
|
+
export type DataOperationParameterLocation = 'body' | 'cookie' | 'header' | 'path' | 'query';
|
|
21
|
+
|
|
22
|
+
export interface DataOperationParameter extends DataSchemaSlot {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly location: DataOperationParameterLocation;
|
|
25
|
+
readonly required?: boolean;
|
|
26
|
+
readonly description?: string;
|
|
27
|
+
readonly default?: DataContractValue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DataOperationRequest extends DataSchemaSlot {
|
|
31
|
+
readonly parameters?: readonly DataOperationParameter[];
|
|
32
|
+
readonly contentType?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DataOperationResponse extends DataSchemaSlot {
|
|
36
|
+
readonly status?: number | string;
|
|
37
|
+
readonly contentType?: string;
|
|
38
|
+
readonly description?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface DataOperationPagination {
|
|
42
|
+
readonly kind: 'cursor' | 'limit-offset' | 'page' | 'unknown' | (string & {});
|
|
43
|
+
readonly cursorPath?: string;
|
|
44
|
+
readonly limitParameter?: string;
|
|
45
|
+
readonly offsetParameter?: string;
|
|
46
|
+
readonly pageParameter?: string;
|
|
47
|
+
readonly pageSizeParameter?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface DataOperationConfig {
|
|
51
|
+
readonly id: OperationId;
|
|
52
|
+
readonly endpointId?: EndpointId;
|
|
53
|
+
readonly name?: string;
|
|
54
|
+
readonly description?: string;
|
|
55
|
+
readonly protocol: DataOperationProtocol;
|
|
56
|
+
readonly intent: DataOperationIntent;
|
|
57
|
+
readonly method?: DataOperationMethod;
|
|
58
|
+
readonly path?: string;
|
|
59
|
+
readonly request?: DataOperationRequest;
|
|
60
|
+
readonly response?: DataOperationResponse;
|
|
61
|
+
readonly pagination?: DataOperationPagination;
|
|
62
|
+
readonly credential?: CredentialRef;
|
|
63
|
+
readonly metadata?: DataContractValue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type DataOperationRegistry = Readonly<Record<OperationId, DataOperationConfig>>;
|
package/src/data/refs.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AdapterId, CredentialId } from './ids';
|
|
2
|
+
import type { DataContractValue } from './values';
|
|
3
|
+
|
|
4
|
+
export type CredentialKind = 'apiKey' | 'basic' | 'bearer' | 'custom' | 'oauth2';
|
|
5
|
+
|
|
6
|
+
export interface CredentialRef {
|
|
7
|
+
readonly id: CredentialId;
|
|
8
|
+
readonly kind: CredentialKind | (string & {});
|
|
9
|
+
readonly label?: string;
|
|
10
|
+
readonly scope?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type AdapterKind = 'auth' | 'database' | 'storage' | 'transport' | (string & {});
|
|
14
|
+
|
|
15
|
+
export interface AdapterRef {
|
|
16
|
+
readonly id: AdapterId;
|
|
17
|
+
readonly kind: AdapterKind;
|
|
18
|
+
readonly packageName?: string;
|
|
19
|
+
readonly exportName?: string;
|
|
20
|
+
readonly config?: DataContractValue;
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SchemaId } from './ids';
|
|
2
|
+
import type { DataContractValue } from './values';
|
|
3
|
+
|
|
4
|
+
export type DataSchemaPrimitiveType =
|
|
5
|
+
| 'array'
|
|
6
|
+
| 'boolean'
|
|
7
|
+
| 'integer'
|
|
8
|
+
| 'null'
|
|
9
|
+
| 'number'
|
|
10
|
+
| 'object'
|
|
11
|
+
| 'string';
|
|
12
|
+
|
|
13
|
+
export interface DataSchemaRef {
|
|
14
|
+
readonly id: SchemaId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface DataSchemaProperty {
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
readonly schema: DataSchema;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DataSchema {
|
|
23
|
+
readonly type?: DataSchemaPrimitiveType | readonly DataSchemaPrimitiveType[];
|
|
24
|
+
readonly title?: string;
|
|
25
|
+
readonly description?: string;
|
|
26
|
+
readonly enum?: readonly DataContractValue[];
|
|
27
|
+
readonly const?: DataContractValue;
|
|
28
|
+
readonly default?: DataContractValue;
|
|
29
|
+
readonly format?: string;
|
|
30
|
+
readonly nullable?: boolean;
|
|
31
|
+
readonly required?: readonly string[];
|
|
32
|
+
readonly properties?: Readonly<Record<string, DataSchema>>;
|
|
33
|
+
readonly additionalProperties?: boolean | DataSchema;
|
|
34
|
+
readonly items?: DataSchema;
|
|
35
|
+
readonly allOf?: readonly DataSchema[];
|
|
36
|
+
readonly anyOf?: readonly DataSchema[];
|
|
37
|
+
readonly oneOf?: readonly DataSchema[];
|
|
38
|
+
readonly ref?: DataSchemaRef;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type DataSchemaRegistry = Readonly<Record<SchemaId, DataSchema>>;
|
|
42
|
+
|
|
43
|
+
export interface DataSchemaSlot {
|
|
44
|
+
readonly schema?: DataSchema;
|
|
45
|
+
readonly schemaRef?: DataSchemaRef;
|
|
46
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { DbCollectionDefinition } from '../db';
|
|
2
|
+
import type { DataEndpointRegistry } from './endpoints';
|
|
3
|
+
import type { DataSourceId } from './ids';
|
|
4
|
+
import type { AdapterRef, CredentialRef } from './refs';
|
|
5
|
+
import type { DataSchemaRegistry } from './schemas';
|
|
6
|
+
import type { DataContractValue } from './values';
|
|
7
|
+
|
|
8
|
+
export type DataSourceKind = 'database' | 'graphql' | 'managed-api' | 'openapi' | 'rest';
|
|
9
|
+
|
|
10
|
+
export interface DataSourceBaseConfig {
|
|
11
|
+
readonly id: DataSourceId;
|
|
12
|
+
readonly kind: DataSourceKind;
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
readonly credential?: CredentialRef;
|
|
16
|
+
readonly endpoints: DataEndpointRegistry;
|
|
17
|
+
readonly schemas?: DataSchemaRegistry;
|
|
18
|
+
readonly metadata?: DataContractValue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface RestDataSourceConfig extends DataSourceBaseConfig {
|
|
22
|
+
readonly kind: 'rest';
|
|
23
|
+
readonly baseUrl: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface OpenApiImportRef {
|
|
27
|
+
readonly url?: string;
|
|
28
|
+
readonly documentId?: string;
|
|
29
|
+
readonly version?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface OpenApiDataSourceConfig extends DataSourceBaseConfig {
|
|
33
|
+
readonly kind: 'openapi';
|
|
34
|
+
readonly baseUrl?: string;
|
|
35
|
+
readonly import?: OpenApiImportRef;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface GraphQlDataSourceConfig extends DataSourceBaseConfig {
|
|
39
|
+
readonly kind: 'graphql';
|
|
40
|
+
readonly endpointUrl: string;
|
|
41
|
+
readonly introspection?: {
|
|
42
|
+
readonly enabled: boolean;
|
|
43
|
+
readonly schemaVersion?: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface DatabaseDataSourceConfig extends DataSourceBaseConfig {
|
|
48
|
+
readonly kind: 'database';
|
|
49
|
+
readonly adapter: AdapterRef;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ManagedApiResourceConfig {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly collection: DbCollectionDefinition;
|
|
55
|
+
readonly operations?: readonly ('create' | 'delete' | 'list' | 'read' | 'update')[];
|
|
56
|
+
readonly metadata?: DataContractValue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ManagedApiDataSourceConfig extends DataSourceBaseConfig {
|
|
60
|
+
readonly kind: 'managed-api';
|
|
61
|
+
readonly adapter: AdapterRef;
|
|
62
|
+
readonly resources: readonly ManagedApiResourceConfig[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type DataSourceConfig =
|
|
66
|
+
| DatabaseDataSourceConfig
|
|
67
|
+
| GraphQlDataSourceConfig
|
|
68
|
+
| ManagedApiDataSourceConfig
|
|
69
|
+
| OpenApiDataSourceConfig
|
|
70
|
+
| RestDataSourceConfig;
|
|
71
|
+
|
|
72
|
+
export type DataSourceRegistry = Readonly<Record<DataSourceId, DataSourceConfig>>;
|