@auxx/sdk 0.0.25 → 0.0.27
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/lib/build/server/generate-server-entry.js +1 -1
- package/lib/root/app.d.ts +2 -0
- package/lib/root/app.d.ts.map +1 -1
- package/lib/root/data-connectors/define-data-connector.d.ts.map +1 -1
- package/lib/root/data-connectors/define-data-connector.js +55 -2
- package/lib/root/data-connectors/index.d.ts +1 -1
- package/lib/root/data-connectors/index.d.ts.map +1 -1
- package/lib/root/data-connectors/types.d.ts +68 -61
- package/lib/root/data-connectors/types.d.ts.map +1 -1
- package/lib/root/entities/define-entity.d.ts +16 -0
- package/lib/root/entities/define-entity.d.ts.map +1 -0
- package/lib/root/entities/define-entity.js +39 -0
- package/lib/root/entities/index.d.ts +2 -0
- package/lib/root/entities/index.d.ts.map +1 -0
- package/lib/root/entities/index.js +1 -0
- package/lib/root/fields/define-field.d.ts +35 -15
- package/lib/root/fields/define-field.d.ts.map +1 -1
- package/lib/root/fields/define-field.js +10 -9
- package/lib/root/fields/field-types.d.ts +1 -2
- package/lib/root/fields/field-types.d.ts.map +1 -1
- package/lib/root/fields/field-types.js +0 -1
- package/lib/root/fields/index.d.ts +1 -1
- package/lib/root/fields/index.d.ts.map +1 -1
- package/lib/root/index.d.ts +3 -2
- package/lib/root/index.d.ts.map +1 -1
- package/lib/root/index.js +1 -0
- package/lib/root/tools/types.d.ts +1 -1
- package/lib/root/tools/types.d.ts.map +1 -1
- package/lib/util/compile-and-extract-catalog.js +190 -47
- package/package.json +5 -1
|
@@ -172,7 +172,7 @@ export async function generateServerEntry({ appDirAbsolute, srcDirAbsolute, webh
|
|
|
172
172
|
// Build __AUXX_DATA_CONNECTORS__ — the connector registry read by the
|
|
173
173
|
// lambda data-connector-executor. Mirrors __AUXX_TOOLS__: the executor
|
|
174
174
|
// reads execute({ streamKey, mode, state, connection, config }) off this
|
|
175
|
-
// global. See
|
|
175
|
+
// global. See docs/app-fields-and-entities-guide.md.
|
|
176
176
|
const __AUXX_DATA_CONNECTORS__ = {};
|
|
177
177
|
|
|
178
178
|
for (const [connectorId, handlers] of dataConnectorModulesMap.entries()) {
|
package/lib/root/app.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BulkRecordAction, RecordAction, RecordWidget } from '../client/record-actions.js';
|
|
2
2
|
import type { DataConnectorDefinition } from './data-connectors/types.js';
|
|
3
|
+
import type { EntityDecl } from './entities/index.js';
|
|
3
4
|
import type { AppFieldDefinition } from './fields/index.js';
|
|
4
5
|
import type { ScopedSettingsSchema } from './settings/settings-schema.js';
|
|
5
6
|
import type { ToolDefinition, Toolset } from './tools/types.js';
|
|
@@ -51,6 +52,7 @@ export interface App {
|
|
|
51
52
|
readonly tools?: ReadonlyArray<ToolDefinition>;
|
|
52
53
|
readonly toolsets?: ReadonlyArray<Toolset>;
|
|
53
54
|
readonly fields?: ReadonlyArray<AppFieldDefinition>;
|
|
55
|
+
readonly entities?: ReadonlyArray<EntityDecl>;
|
|
54
56
|
readonly dataConnectors?: ReadonlyArray<DataConnectorDefinition>;
|
|
55
57
|
readonly settings?: {
|
|
56
58
|
readonly organization?: ScopedSettingsSchema;
|
package/lib/root/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/root/app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,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AAC,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;SACrC,CAAA;QACD,QAAQ,CAAC,UAAU,CAAC,EAAE;YACpB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;SACpC,CAAA;KACF,CAAA;IAED,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAElB,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;QAEjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;KAC9B,CAAA;IAOD,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAK9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;IAU1C,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAA;IASnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IAc7C,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAA;IAEhE,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAA;KAC7C,CAAA;CAIF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-data-connector.d.ts","sourceRoot":"","sources":["../../../src/root/data-connectors/define-data-connector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"define-data-connector.d.ts","sourceRoot":"","sources":["../../../src/root/data-connectors/define-data-connector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAoB,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAqL3E,wBAAgB,mBAAmB,CAAC,aAAa,SAAS,CAAC,CAAC,UAAU,EACpE,SAAS,EAAE,uBAAuB,CAAC,aAAa,CAAC,GAChD,uBAAuB,CAAC,aAAa,CAAC,CA2CxC"}
|
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
const CONNECTOR_ID_RE = /^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*$/;
|
|
2
|
+
function assertValidMapping(connectorId, streamKey, mapping) {
|
|
3
|
+
const target = mapping.target;
|
|
4
|
+
const hasEntityKey = 'entityKey' in target;
|
|
5
|
+
const hasEntityKind = 'entityKind' in target;
|
|
6
|
+
if (hasEntityKey === hasEntityKind) {
|
|
7
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": target must name exactly one of entityKey or entityKind`);
|
|
8
|
+
}
|
|
9
|
+
if (hasEntityKey) {
|
|
10
|
+
if (mapping.connectionFields) {
|
|
11
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": connectionFields is only valid on a contributing (entityKind) mapping`);
|
|
12
|
+
}
|
|
13
|
+
for (const field of mapping.fields ?? []) {
|
|
14
|
+
const owned = field;
|
|
15
|
+
if (!owned.key || !owned.sourcePath) {
|
|
16
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": every owned field needs a key and a sourcePath`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const contributing = mapping;
|
|
22
|
+
for (const field of contributing.fields ?? []) {
|
|
23
|
+
if (field.constant !== undefined) {
|
|
24
|
+
if (field.sourcePath) {
|
|
25
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": field with constant ${JSON.stringify(field.constant)} cannot also set a sourcePath`);
|
|
26
|
+
}
|
|
27
|
+
if (!field.target || field.appField) {
|
|
28
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": a constant field needs a target and cannot set appField`);
|
|
29
|
+
}
|
|
30
|
+
if (field.match) {
|
|
31
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": constant field "${String(field.target)}" cannot be a match key`);
|
|
32
|
+
}
|
|
33
|
+
const t = typeof field.constant;
|
|
34
|
+
if (t !== 'string' && t !== 'number' && t !== 'boolean') {
|
|
35
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": constant field "${String(field.target)}" must be a string, number, or boolean`);
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!field.sourcePath) {
|
|
40
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": every contributing field needs a sourcePath or a constant`);
|
|
41
|
+
}
|
|
42
|
+
if (field.target && field.appField) {
|
|
43
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": field "${field.sourcePath}" cannot set both target and appField`);
|
|
44
|
+
}
|
|
45
|
+
if (!field.target && !field.appField && !(field.type && field.name)) {
|
|
46
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": field "${field.sourcePath}" needs a target, an appField, or both type and name (source-only projection)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const conn of contributing.connectionFields ?? []) {
|
|
50
|
+
if (!conn.appField || !conn.from) {
|
|
51
|
+
throw new Error(`defineDataConnector: connector "${connectorId}" stream "${streamKey}" mapping "${mapping.rootPath}": every connectionFields entry needs appField and from`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
2
55
|
export function defineDataConnector(connector) {
|
|
3
56
|
if (!CONNECTOR_ID_RE.test(connector.id)) {
|
|
4
57
|
throw new Error(`defineDataConnector: invalid id "${connector.id}" — must match ${CONNECTOR_ID_RE.source}`);
|
|
@@ -15,8 +68,8 @@ export function defineDataConnector(connector) {
|
|
|
15
68
|
throw new Error(`defineDataConnector: connector "${connector.id}" has duplicate stream key "${stream.key}"`);
|
|
16
69
|
}
|
|
17
70
|
seenStreamKeys.add(stream.key);
|
|
18
|
-
|
|
19
|
-
|
|
71
|
+
for (const mapping of stream.mappings ?? []) {
|
|
72
|
+
assertValidMapping(connector.id, stream.key, mapping);
|
|
20
73
|
}
|
|
21
74
|
if (stream.exampleRecord !== undefined) {
|
|
22
75
|
try {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { defineDataConnector } from './define-data-connector.js';
|
|
2
|
-
export type { ConnectorConnection,
|
|
2
|
+
export type { ConnectorConnection, ConnectorConnectionField, ConnectorContributingFieldConstant, ConnectorContributingFieldSourceOnly, ConnectorContributingFieldToAppField, ConnectorContributingFieldToTarget, ConnectorContributingMappingField, ConnectorExecute, ConnectorExecuteArgs, ConnectorFetchResult, ConnectorMapping, ConnectorOwnedMappingField, ConnectorRecord, ConnectorStreamDecl, ConnectorStreamState, ContributingConnectorMapping, DataConnectorDefinition, FieldMergeStrategy, OwnedConnectorMapping, } from './types.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/root/data-connectors/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/root/data-connectors/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,kCAAkC,EAClC,oCAAoC,EACpC,oCAAoC,EACpC,kCAAkC,EAClC,iCAAiC,EACjC,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,YAAY,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { z } from 'zod/v4';
|
|
2
|
-
import type {
|
|
3
|
-
import type { ActionInputHint } from '../tools/types.js';
|
|
2
|
+
import type { FieldType } from '../fields/field-types.js';
|
|
3
|
+
import type { ActionInputHint, EntityRefKind } from '../tools/types.js';
|
|
4
4
|
export interface ConnectorRecord {
|
|
5
5
|
streamKey: string;
|
|
6
6
|
externalId: string;
|
|
@@ -22,70 +22,76 @@ export interface ConnectorFetchResult {
|
|
|
22
22
|
retryAfterMs?: number;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
25
|
+
export type FieldMergeStrategy = 'overwrite' | 'fill_blank' | 'connector_owned_only' | 'manual_review' | 'ignore';
|
|
26
|
+
export interface ConnectorOwnedMappingField {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly sourcePath: string;
|
|
29
|
+
}
|
|
30
|
+
interface ConnectorContributingFieldCommon {
|
|
31
|
+
readonly mergeStrategy?: FieldMergeStrategy;
|
|
32
|
+
}
|
|
33
|
+
interface ConnectorContributingFieldBase extends ConnectorContributingFieldCommon {
|
|
34
|
+
readonly sourcePath: string;
|
|
35
|
+
readonly constant?: never;
|
|
36
|
+
readonly match?: boolean | 'exclusive';
|
|
37
|
+
}
|
|
38
|
+
export interface ConnectorContributingFieldToTarget extends ConnectorContributingFieldBase {
|
|
39
|
+
readonly target: string;
|
|
40
|
+
readonly appField?: never;
|
|
41
|
+
readonly type?: never;
|
|
42
|
+
readonly name?: never;
|
|
43
|
+
}
|
|
44
|
+
export interface ConnectorContributingFieldToAppField extends ConnectorContributingFieldBase {
|
|
45
|
+
readonly appField: string;
|
|
46
|
+
readonly target?: never;
|
|
47
|
+
readonly type?: never;
|
|
48
|
+
readonly name?: never;
|
|
49
|
+
}
|
|
50
|
+
export interface ConnectorContributingFieldSourceOnly extends ConnectorContributingFieldBase {
|
|
51
|
+
readonly type: FieldType;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly target?: never;
|
|
54
|
+
readonly appField?: never;
|
|
55
|
+
}
|
|
56
|
+
export interface ConnectorContributingFieldConstant extends ConnectorContributingFieldCommon {
|
|
57
|
+
readonly constant: string | number | boolean;
|
|
58
|
+
readonly target: string;
|
|
59
|
+
readonly sourcePath?: never;
|
|
60
|
+
readonly appField?: never;
|
|
61
|
+
readonly match?: never;
|
|
62
|
+
readonly type?: never;
|
|
63
|
+
readonly name?: never;
|
|
64
|
+
}
|
|
65
|
+
export type ConnectorContributingMappingField = ConnectorContributingFieldToTarget | ConnectorContributingFieldToAppField | ConnectorContributingFieldSourceOnly | ConnectorContributingFieldConstant;
|
|
66
|
+
export interface ConnectorConnectionField {
|
|
67
|
+
readonly appField: string;
|
|
68
|
+
readonly from: string;
|
|
69
|
+
}
|
|
70
|
+
interface ConnectorMappingBase {
|
|
71
|
+
readonly rootPath: string;
|
|
72
|
+
readonly parentRootPath?: string;
|
|
73
|
+
readonly linkMode?: 'upsert' | 'reference';
|
|
74
|
+
readonly relationshipFieldKey?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface OwnedConnectorMapping extends ConnectorMappingBase {
|
|
77
|
+
readonly target: {
|
|
78
|
+
readonly entityKey: string;
|
|
79
|
+
};
|
|
80
|
+
readonly fields?: readonly ConnectorOwnedMappingField[];
|
|
81
|
+
readonly connectionFields?: never;
|
|
82
|
+
}
|
|
83
|
+
export interface ContributingConnectorMapping extends ConnectorMappingBase {
|
|
84
|
+
readonly target: {
|
|
85
|
+
readonly entityKind: EntityRefKind;
|
|
81
86
|
};
|
|
87
|
+
readonly fields?: readonly ConnectorContributingMappingField[];
|
|
88
|
+
readonly connectionFields?: readonly ConnectorConnectionField[];
|
|
82
89
|
}
|
|
90
|
+
export type ConnectorMapping = OwnedConnectorMapping | ContributingConnectorMapping;
|
|
83
91
|
export interface ConnectorStreamDecl {
|
|
84
92
|
key: string;
|
|
85
|
-
displayFieldKey: string;
|
|
86
93
|
syncMode?: 'snapshot' | 'incremental';
|
|
87
|
-
|
|
88
|
-
defaultMappings?: ConnectorDefaultMapping[];
|
|
94
|
+
mappings: ConnectorMapping[];
|
|
89
95
|
exampleRecord?: Record<string, unknown>;
|
|
90
96
|
webhookTrigger?: {
|
|
91
97
|
filter?: Record<string, unknown>;
|
|
@@ -121,4 +127,5 @@ export interface DataConnectorDefinition<TConfigSchema extends z.ZodTypeAny = z.
|
|
|
121
127
|
};
|
|
122
128
|
execute: ConnectorExecute<z.output<TConfigSchema>>;
|
|
123
129
|
}
|
|
130
|
+
export {};
|
|
124
131
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/root/data-connectors/types.ts"],"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AEb,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,kBAAkB,EAAE,OAAO,CAAA;IAE3B,MAAM,EAAE,aAAa,CAAA;IASrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAE/C,OAAO,EAAE,mBAAmB,EAAE,CAAA;IAE9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAKhB,cAAc,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IAMtC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAA;CACnD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type FieldDecl } from '../fields/define-field.js';
|
|
2
|
+
export interface EntityDecl {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly apiSlug: string;
|
|
5
|
+
readonly singular: string;
|
|
6
|
+
readonly plural: string;
|
|
7
|
+
readonly description?: string;
|
|
8
|
+
readonly icon?: string;
|
|
9
|
+
readonly color?: string;
|
|
10
|
+
readonly primaryDisplayField: string;
|
|
11
|
+
readonly secondaryDisplayField?: string;
|
|
12
|
+
readonly avatarField?: string;
|
|
13
|
+
readonly fields: readonly FieldDecl[];
|
|
14
|
+
}
|
|
15
|
+
export declare function defineEntity<const E extends EntityDecl>(entity: E): E;
|
|
16
|
+
//# sourceMappingURL=define-entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-entity.d.ts","sourceRoot":"","sources":["../../../src/root/entities/define-entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAiBpF,MAAM,WAAW,UAAU;IAQzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAGpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IAGvB,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IAGpC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAGvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAO7B,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;CACtC;AA+BD,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,UAAU,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAgDrE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { assertValidIdentityField } from '../fields/define-field.js';
|
|
2
|
+
const ENTITY_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/;
|
|
3
|
+
const API_SLUG_RE = /^[a-z][a-z0-9_]*$/;
|
|
4
|
+
export function defineEntity(entity) {
|
|
5
|
+
if (!ENTITY_KEY_RE.test(entity.key)) {
|
|
6
|
+
throw new Error(`defineEntity: invalid key "${entity.key}" — must match ${ENTITY_KEY_RE.source}`);
|
|
7
|
+
}
|
|
8
|
+
if (!API_SLUG_RE.test(entity.apiSlug)) {
|
|
9
|
+
throw new Error(`defineEntity "${entity.key}": invalid apiSlug "${entity.apiSlug}" — must match ${API_SLUG_RE.source}`);
|
|
10
|
+
}
|
|
11
|
+
const fieldKeys = new Set();
|
|
12
|
+
let identityFieldKey;
|
|
13
|
+
for (const field of entity.fields) {
|
|
14
|
+
if (!ENTITY_KEY_RE.test(field.key)) {
|
|
15
|
+
throw new Error(`defineEntity "${entity.key}": invalid field key "${field.key}" — must match ${ENTITY_KEY_RE.source}`);
|
|
16
|
+
}
|
|
17
|
+
if (fieldKeys.has(field.key)) {
|
|
18
|
+
throw new Error(`defineEntity "${entity.key}": duplicate field key "${field.key}"`);
|
|
19
|
+
}
|
|
20
|
+
fieldKeys.add(field.key);
|
|
21
|
+
assertValidIdentityField(field);
|
|
22
|
+
if (field.identity) {
|
|
23
|
+
if (identityFieldKey !== undefined) {
|
|
24
|
+
throw new Error(`defineEntity "${entity.key}": more than one identity field ("${identityFieldKey}" and "${field.key}") — at most one identity field is allowed per entity`);
|
|
25
|
+
}
|
|
26
|
+
identityFieldKey = field.key;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const [label, fieldKey] of [
|
|
30
|
+
['primaryDisplayField', entity.primaryDisplayField],
|
|
31
|
+
['secondaryDisplayField', entity.secondaryDisplayField],
|
|
32
|
+
['avatarField', entity.avatarField],
|
|
33
|
+
]) {
|
|
34
|
+
if (fieldKey !== undefined && !fieldKeys.has(fieldKey)) {
|
|
35
|
+
throw new Error(`defineEntity "${entity.key}": ${label} "${fieldKey}" is not a declared field`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return entity;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/root/entities/index.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineEntity } from './define-entity.js';
|
|
@@ -1,46 +1,66 @@
|
|
|
1
1
|
import type { EntityRefKind } from '../tools/types.js';
|
|
2
2
|
import type { FieldCapabilities, FieldScope, FieldSelectOption, FieldType } from './field-types.js';
|
|
3
3
|
type SelectFieldType = 'SINGLE_SELECT' | 'MULTI_SELECT' | 'TAGS';
|
|
4
|
-
type ScalarFieldType = Exclude<FieldType, SelectFieldType | 'RELATIONSHIP' | 'CALC' | 'ACTOR'>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly
|
|
8
|
-
readonly scope: FieldScope;
|
|
4
|
+
type ScalarFieldType = Exclude<FieldType, SelectFieldType | 'RELATIONSHIP' | 'CALC' | 'ADDRESS_STRUCT' | 'ACTOR'>;
|
|
5
|
+
export type FieldDecl = ScalarFieldDecl | AddressStructFieldDecl | SelectFieldDecl | RelationshipFieldDecl | CalcFieldDecl;
|
|
6
|
+
interface BaseFieldDecl {
|
|
7
|
+
readonly key: string;
|
|
9
8
|
readonly name: string;
|
|
10
9
|
readonly description?: string;
|
|
11
10
|
readonly capabilities?: FieldCapabilities;
|
|
12
11
|
readonly identity?: boolean;
|
|
12
|
+
readonly pii?: boolean;
|
|
13
13
|
}
|
|
14
|
-
interface
|
|
14
|
+
interface ScalarFieldDecl extends BaseFieldDecl {
|
|
15
15
|
readonly type: ScalarFieldType;
|
|
16
16
|
readonly options?: never;
|
|
17
|
+
readonly addressComponents?: never;
|
|
17
18
|
readonly relationship?: never;
|
|
18
19
|
readonly calc?: never;
|
|
19
20
|
}
|
|
20
|
-
interface
|
|
21
|
+
interface AddressStructFieldDecl extends BaseFieldDecl {
|
|
22
|
+
readonly type: 'ADDRESS_STRUCT';
|
|
23
|
+
readonly addressComponents?: readonly string[];
|
|
24
|
+
readonly options?: never;
|
|
25
|
+
readonly relationship?: never;
|
|
26
|
+
readonly calc?: never;
|
|
27
|
+
}
|
|
28
|
+
interface SelectFieldDecl extends BaseFieldDecl {
|
|
21
29
|
readonly type: SelectFieldType;
|
|
22
30
|
readonly options: readonly FieldSelectOption[];
|
|
31
|
+
readonly addressComponents?: never;
|
|
23
32
|
readonly relationship?: never;
|
|
24
33
|
readonly calc?: never;
|
|
25
34
|
}
|
|
26
|
-
interface
|
|
35
|
+
interface RelationshipFieldDecl extends BaseFieldDecl {
|
|
27
36
|
readonly type: 'RELATIONSHIP';
|
|
28
37
|
readonly relationship: {
|
|
29
|
-
readonly
|
|
30
|
-
|
|
38
|
+
readonly target: {
|
|
39
|
+
readonly entityKey: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly entityKind: EntityRefKind;
|
|
42
|
+
};
|
|
43
|
+
readonly cardinality: 'has_many' | 'has_one' | 'belongs_to' | 'many_to_many';
|
|
44
|
+
readonly inverseName?: string;
|
|
31
45
|
};
|
|
32
46
|
readonly options?: never;
|
|
47
|
+
readonly addressComponents?: never;
|
|
33
48
|
readonly calc?: never;
|
|
34
49
|
}
|
|
35
|
-
interface
|
|
50
|
+
interface CalcFieldDecl extends BaseFieldDecl {
|
|
36
51
|
readonly type: 'CALC';
|
|
37
52
|
readonly calc: {
|
|
38
53
|
readonly expression: string;
|
|
39
54
|
};
|
|
40
55
|
readonly options?: never;
|
|
56
|
+
readonly addressComponents?: never;
|
|
41
57
|
readonly relationship?: never;
|
|
42
58
|
}
|
|
43
|
-
export type AppFieldDefinition =
|
|
59
|
+
export type AppFieldDefinition = FieldDecl & {
|
|
60
|
+
readonly targetEntity: EntityRefKind;
|
|
61
|
+
readonly scope: FieldScope;
|
|
62
|
+
};
|
|
63
|
+
export declare function assertValidIdentityField(field: FieldDecl): void;
|
|
44
64
|
export declare function defineField<const F extends AppFieldDefinition>(field: F): F;
|
|
45
65
|
export declare function defineFields<const F extends readonly AppFieldDefinition[]>(fields: F): F;
|
|
46
66
|
type OptionValues<F> = F extends {
|
|
@@ -48,7 +68,7 @@ type OptionValues<F> = F extends {
|
|
|
48
68
|
} ? O extends {
|
|
49
69
|
value: infer V;
|
|
50
70
|
} ? V : string : string;
|
|
51
|
-
export type FieldValueType<F extends
|
|
71
|
+
export type FieldValueType<F extends FieldDecl> = F extends {
|
|
52
72
|
type: 'SINGLE_SELECT';
|
|
53
73
|
} ? OptionValues<F> : F extends {
|
|
54
74
|
type: 'MULTI_SELECT' | 'TAGS';
|
|
@@ -61,8 +81,8 @@ export type FieldValueType<F extends AppFieldDefinition> = F extends {
|
|
|
61
81
|
} ? unknown : F extends {
|
|
62
82
|
type: 'RELATIONSHIP';
|
|
63
83
|
} ? string : string;
|
|
64
|
-
export type AppFieldValues<F extends readonly
|
|
65
|
-
[K in F[number] as K['
|
|
84
|
+
export type AppFieldValues<F extends readonly FieldDecl[]> = {
|
|
85
|
+
[K in F[number] as K['key']]: FieldValueType<K>;
|
|
66
86
|
};
|
|
67
87
|
export {};
|
|
68
88
|
//# sourceMappingURL=define-field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-field.d.ts","sourceRoot":"","sources":["../../../src/root/fields/define-field.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"define-field.d.ts","sourceRoot":"","sources":["../../../src/root/fields/define-field.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAQnG,KAAK,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,MAAM,CAAA;AAQhE,KAAK,eAAe,GAAG,OAAO,CAC5B,SAAS,EACT,eAAe,GAAG,cAAc,GAAG,MAAM,GAAG,gBAAgB,GAAG,OAAO,CACvE,CAAA;AAYD,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,sBAAsB,GACtB,eAAe,GACf,qBAAqB,GACrB,aAAa,CAAA;AAGjB,UAAU,aAAa;IAIrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAYzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAM3B,QAAQ,CAAC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CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACjF,YAAY,CAAC,CAAC,CAAC,GACf,CAAC,SAAS;IAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAAA;CAAE,GACzC,YAAY,CAAC,CAAC,CAAC,EAAE,GACjB,CAAC,SAAS;IAAE,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAA;CAAE,GACvC,MAAM,GACN,CAAC,SAAS;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAC5B,OAAO,GACP,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACxB,OAAO,GACP,CAAC,SAAS;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GAChC,MAAM,GACN,MAAM,CAAA;AAMpB,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,SAAS,EAAE,IAAI;KAC1D,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC;CAChD,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const FIELD_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/;
|
|
2
2
|
const NON_IDENTITY_FIELD_TYPES = new Set([
|
|
3
3
|
'RELATIONSHIP',
|
|
4
4
|
'CALC',
|
|
@@ -7,19 +7,20 @@ const NON_IDENTITY_FIELD_TYPES = new Set([
|
|
|
7
7
|
'TAGS',
|
|
8
8
|
'FILE',
|
|
9
9
|
'JSON',
|
|
10
|
+
'ADDRESS_STRUCT',
|
|
10
11
|
'ACTOR',
|
|
11
12
|
]);
|
|
12
|
-
function assertValidIdentityField(field) {
|
|
13
|
+
export function assertValidIdentityField(field) {
|
|
13
14
|
if (!field.identity)
|
|
14
15
|
return;
|
|
15
16
|
if (NON_IDENTITY_FIELD_TYPES.has(field.type)) {
|
|
16
|
-
throw new Error(`defineField: "${field.
|
|
17
|
+
throw new Error(`defineField: "${field.key}" cannot be identity: true with type "${field.type}" — ` +
|
|
17
18
|
'identity fields must be a scalar single-value type (TEXT unless another scalar is needed)');
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
export function defineField(field) {
|
|
21
|
-
if (!
|
|
22
|
-
throw new Error(`defineField: invalid
|
|
22
|
+
if (!FIELD_KEY_RE.test(field.key)) {
|
|
23
|
+
throw new Error(`defineField: invalid key "${field.key}" — must match ${FIELD_KEY_RE.source}`);
|
|
23
24
|
}
|
|
24
25
|
assertValidIdentityField(field);
|
|
25
26
|
return field;
|
|
@@ -27,12 +28,12 @@ export function defineField(field) {
|
|
|
27
28
|
export function defineFields(fields) {
|
|
28
29
|
const seen = new Set();
|
|
29
30
|
for (const field of fields) {
|
|
30
|
-
if (!
|
|
31
|
-
throw new Error(`defineFields: invalid
|
|
31
|
+
if (!FIELD_KEY_RE.test(field.key)) {
|
|
32
|
+
throw new Error(`defineFields: invalid key "${field.key}" — must match ${FIELD_KEY_RE.source}`);
|
|
32
33
|
}
|
|
33
|
-
const dedupeKey = `${field.targetEntity}:${field.
|
|
34
|
+
const dedupeKey = `${field.targetEntity}:${field.key}`;
|
|
34
35
|
if (seen.has(dedupeKey)) {
|
|
35
|
-
throw new Error(`defineFields: duplicate
|
|
36
|
+
throw new Error(`defineFields: duplicate key "${field.key}" on entity "${field.targetEntity}"`);
|
|
36
37
|
}
|
|
37
38
|
seen.add(dedupeKey);
|
|
38
39
|
assertValidIdentityField(field);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const FIELD_TYPES: readonly ["TEXT", "EMAIL", "URL", "RICH_TEXT", "
|
|
1
|
+
export declare const FIELD_TYPES: readonly ["TEXT", "EMAIL", "URL", "RICH_TEXT", "PHONE_INTL", "ADDRESS", "ADDRESS_STRUCT", "FILE", "DATE", "DATETIME", "TIME", "NUMBER", "CURRENCY", "CHECKBOX", "JSON", "NAME", "SINGLE_SELECT", "MULTI_SELECT", "TAGS", "RELATIONSHIP", "CALC", "ACTOR"];
|
|
2
2
|
export type FieldType = (typeof FIELD_TYPES)[number];
|
|
3
3
|
export interface FieldCapabilities {
|
|
4
4
|
filterable?: boolean;
|
|
@@ -21,7 +21,6 @@ export interface FieldTypeValueMap {
|
|
|
21
21
|
EMAIL: string;
|
|
22
22
|
URL: string;
|
|
23
23
|
RICH_TEXT: string;
|
|
24
|
-
PHONE: string;
|
|
25
24
|
PHONE_INTL: string;
|
|
26
25
|
ADDRESS: string;
|
|
27
26
|
DATE: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/root/fields/field-types.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/root/fields/field-types.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW,2PAuBd,CAAA;AAQV,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAOpD,MAAM,WAAW,iBAAiB;IAEhC,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,SAAS,CAAC,EAAE,OAAO,CAAA;IAGnB,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAIlB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAGD,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,YAAY,CAAA;AAGtD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AASD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CACzB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { type AppFieldDefinition, type AppFieldValues, defineField, defineFields, type FieldValueType, } from './define-field.js';
|
|
1
|
+
export { type AppFieldDefinition, type AppFieldValues, defineField, defineFields, type FieldDecl, type FieldValueType, } from './define-field.js';
|
|
2
2
|
export { FIELD_TYPES, type FieldCapabilities, type FieldScope, type FieldSelectOption, type FieldType, type FieldTypeValueMap, } from './field-types.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/root/fields/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/root/fields/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,WAAW,EACX,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAA"}
|
package/lib/root/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ export type { BulkRecordAction, RecordAction, RecordActionContext, } from '../cl
|
|
|
2
2
|
export type { TriggerContext, WorkflowContext, WorkflowInput, WorkflowOutput, } from '../server/workflow/index.js';
|
|
3
3
|
export { parseScopeString, resolveCapabilities } from '../shared/scopes.js';
|
|
4
4
|
export type { App, AppSettings, Permission } from './app.js';
|
|
5
|
-
export type { ConnectorConnection,
|
|
5
|
+
export type { ConnectorConnection, ConnectorConnectionField, ConnectorContributingFieldConstant, ConnectorContributingFieldSourceOnly, ConnectorContributingFieldToAppField, ConnectorContributingFieldToTarget, ConnectorContributingMappingField, ConnectorExecute, ConnectorExecuteArgs, ConnectorFetchResult, ConnectorMapping, ConnectorOwnedMappingField, ConnectorRecord, ConnectorStreamDecl, ConnectorStreamState, ContributingConnectorMapping, DataConnectorDefinition, FieldMergeStrategy, OwnedConnectorMapping, } from './data-connectors/index.js';
|
|
6
6
|
export { defineDataConnector } from './data-connectors/index.js';
|
|
7
|
-
export {
|
|
7
|
+
export { defineEntity, type EntityDecl } from './entities/index.js';
|
|
8
|
+
export { type AppFieldDefinition, type AppFieldValues, defineField, defineFields, FIELD_TYPES, type FieldCapabilities, type FieldDecl, type FieldScope, type FieldSelectOption, type FieldType, type FieldTypeValueMap, type FieldValueType, } from './fields/index.js';
|
|
8
9
|
export { Settings } from './settings/index.js';
|
|
9
10
|
export type { BaseSettingOptions, BooleanSettingOptions, NumberSettingOptions, SelectSettingOptions, SettingsBooleanNode, SettingsNode, SettingsNumberNode, SettingsSchema, SettingsSelectNode, SettingsStringNode, SettingsStructNode, StringSettingOptions, StructSettingOptions, } from './settings/settings-schema.js';
|
|
10
11
|
export type { AuxxRefMeta, EntityRefKind, ToolActionContext, ToolActionEntity, ToolActionParticipant, ToolActionSurface, ToolAgentSurface, ToolConfig, ToolDefinition, ToolExecuteContext, Toolset, } from './tools/index.js';
|
package/lib/root/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/root/index.ts"],"names":[],"mappings":"AASA,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AACpC,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,6BAA6B,CAAA;AAKpC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,YAAY,EACV,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/root/index.ts"],"names":[],"mappings":"AASA,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AACpC,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,6BAA6B,CAAA;AAKpC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,kCAAkC,EAClC,oCAAoC,EACpC,oCAAoC,EACpC,kCAAk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AAkB,EAClB,kBAAkB,EAClB,YAAY,EAEZ,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EAEjB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA"}
|
package/lib/root/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { parseScopeString, resolveCapabilities } from '../shared/scopes.js';
|
|
2
2
|
export { defineDataConnector } from './data-connectors/index.js';
|
|
3
|
+
export { defineEntity } from './entities/index.js';
|
|
3
4
|
export { defineField, defineFields, FIELD_TYPES, } from './fields/index.js';
|
|
4
5
|
export { Settings } from './settings/index.js';
|
|
5
6
|
export { defineTool, refs, z } from './tools/index.js';
|
|
@@ -19,7 +19,7 @@ export interface ToolActionContext {
|
|
|
19
19
|
participants: ToolActionParticipant[];
|
|
20
20
|
entities: ToolActionEntity[];
|
|
21
21
|
}
|
|
22
|
-
export type EntityRefKind = 'contact' | 'company' | 'ticket' | 'article' | 'thread' | 'order' | 'invoice' | 'catalog_item' | 'part' | 'product' | 'build' | 'purchase_order' | 'vendor_bill' | 'gl_account'
|
|
22
|
+
export type EntityRefKind = 'contact' | 'company' | 'ticket' | 'article' | 'thread' | 'order' | 'invoice' | 'line_item' | 'catalog_item' | 'part' | 'product' | 'build' | 'purchase_order' | 'vendor_bill' | 'gl_account';
|
|
23
23
|
export interface ToolConfig {
|
|
24
24
|
readonly requiresConnection?: boolean;
|
|
25
25
|
readonly timeout?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/root/tools/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAO/B,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,kBAAkB,EAAE,MAAM,CAAA;IAE1B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IAEnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAKD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,OAAO,CAAA;IAEnB,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAMD,MAAM,WAAW,iBAAiB;IAEhC,QAAQ,EAAE,MAAM,CAAA;IAGhB,MAAM,CAAC,EAAE,gBAAgB,CAAA;IAGzB,YAAY,EAAE,qBAAqB,EAAE,CAAA;IAOrC,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/root/tools/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAO/B,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,kBAAkB,EAAE,MAAM,CAAA;IAE1B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IAEnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAKD,MAAM,WAAW,qBAAqB;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QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAA;IAGjC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CACpC;AAWD,MAAM,WAAW,OAAO;IAEtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;IAEtC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IAMjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAQD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC"}
|
|
@@ -8,6 +8,14 @@ import { complete, errored, isErrored } from '../errors.js';
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
const SDK_ROOT = path.resolve(__dirname, '..', '..');
|
|
11
|
+
const RESERVED_SYSTEM_ATTRIBUTES = new Set([
|
|
12
|
+
'record_id',
|
|
13
|
+
'created_at',
|
|
14
|
+
'updated_at',
|
|
15
|
+
'created_by_id',
|
|
16
|
+
'quote_number',
|
|
17
|
+
'part_quantity_on_hand',
|
|
18
|
+
]);
|
|
11
19
|
export async function compileAndExtractCatalog() {
|
|
12
20
|
const srcDirAbsolute = path.resolve('src');
|
|
13
21
|
const candidates = ['app.ts', 'app.tsx'];
|
|
@@ -45,6 +53,7 @@ export async function compileAndExtractCatalog() {
|
|
|
45
53
|
const SDK_REAL_TOOLS = path.join(SDK_ROOT, 'lib', 'root', 'tools', 'index.js');
|
|
46
54
|
const SDK_REAL_WORKFLOW = path.join(SDK_ROOT, 'lib', 'root', 'workflow', 'index.js');
|
|
47
55
|
const SDK_REAL_FIELDS = path.join(SDK_ROOT, 'lib', 'root', 'fields', 'index.js');
|
|
56
|
+
const SDK_REAL_ENTITIES = path.join(SDK_ROOT, 'lib', 'root', 'entities', 'index.js');
|
|
48
57
|
const SDK_REAL_DATA_CONNECTORS = path.join(SDK_ROOT, 'lib', 'root', 'data-connectors', 'index.js');
|
|
49
58
|
const stubSdkSubpaths = {
|
|
50
59
|
name: 'auxx-stub-sdk-subpaths',
|
|
@@ -58,6 +67,8 @@ export async function compileAndExtractCatalog() {
|
|
|
58
67
|
return { path: SDK_REAL_WORKFLOW };
|
|
59
68
|
if (args.path === '@auxx/sdk/fields')
|
|
60
69
|
return { path: SDK_REAL_FIELDS };
|
|
70
|
+
if (args.path === '@auxx/sdk/entities')
|
|
71
|
+
return { path: SDK_REAL_ENTITIES };
|
|
61
72
|
if (args.path === '@auxx/sdk/data-connectors')
|
|
62
73
|
return { path: SDK_REAL_DATA_CONNECTORS };
|
|
63
74
|
return { path: args.path, namespace: 'auxx-sdk-stub' };
|
|
@@ -124,12 +135,14 @@ export async function compileAndExtractCatalog() {
|
|
|
124
135
|
const workflowBlocksArr = (app.workflow?.blocks ?? []);
|
|
125
136
|
const workflowTriggersArr = (app.workflow?.triggers ?? []);
|
|
126
137
|
const fieldsArr = (app.fields ?? []);
|
|
138
|
+
const entitiesArr = (app.entities ?? []);
|
|
127
139
|
const dataConnectorsArr = (app.dataConnectors ?? []);
|
|
128
140
|
if (!toolsArr.length &&
|
|
129
141
|
!toolsetsArr.length &&
|
|
130
142
|
!workflowBlocksArr.length &&
|
|
131
143
|
!workflowTriggersArr.length &&
|
|
132
144
|
!fieldsArr.length &&
|
|
145
|
+
!entitiesArr.length &&
|
|
133
146
|
!dataConnectorsArr.length) {
|
|
134
147
|
return complete(undefined);
|
|
135
148
|
}
|
|
@@ -291,34 +304,102 @@ export async function compileAndExtractCatalog() {
|
|
|
291
304
|
: {}),
|
|
292
305
|
});
|
|
293
306
|
}
|
|
307
|
+
function projectFieldDecl(field) {
|
|
308
|
+
return {
|
|
309
|
+
key: field.key,
|
|
310
|
+
type: field.type,
|
|
311
|
+
name: field.name,
|
|
312
|
+
description: field.description,
|
|
313
|
+
capabilities: field.capabilities,
|
|
314
|
+
identity: field.identity,
|
|
315
|
+
options: field.options,
|
|
316
|
+
addressComponents: field.addressComponents,
|
|
317
|
+
relationship: field.relationship,
|
|
318
|
+
calc: field.calc,
|
|
319
|
+
pii: field.pii,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
294
322
|
const cataloguedFields = [];
|
|
295
323
|
const seenFieldKeys = new Set();
|
|
324
|
+
const identityFieldByTargetEntity = new Map();
|
|
296
325
|
for (const field of fieldsArr) {
|
|
297
|
-
if (!field?.
|
|
298
|
-
return errored({ code: 'CATALOG_VALIDATION_FAILED', message: 'Field is missing
|
|
326
|
+
if (!field?.key) {
|
|
327
|
+
return errored({ code: 'CATALOG_VALIDATION_FAILED', message: 'Field is missing key' });
|
|
299
328
|
}
|
|
300
|
-
const dedupeKey = `${field.targetEntity}:${field.
|
|
329
|
+
const dedupeKey = `${field.targetEntity}:${field.key}`;
|
|
301
330
|
if (seenFieldKeys.has(dedupeKey)) {
|
|
302
331
|
return errored({
|
|
303
332
|
code: 'CATALOG_VALIDATION_FAILED',
|
|
304
|
-
message: `Duplicate field "${field.
|
|
333
|
+
message: `Duplicate field "${field.key}" on entity "${field.targetEntity}"`,
|
|
305
334
|
});
|
|
306
335
|
}
|
|
307
336
|
seenFieldKeys.add(dedupeKey);
|
|
337
|
+
if (field.identity) {
|
|
338
|
+
const existing = identityFieldByTargetEntity.get(field.targetEntity);
|
|
339
|
+
if (existing) {
|
|
340
|
+
return errored({
|
|
341
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
342
|
+
message: `More than one identity field targets "${field.targetEntity}" ("${existing}" and "${field.key}") — at most one identity field is allowed per entity`,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
identityFieldByTargetEntity.set(field.targetEntity, field.key);
|
|
346
|
+
}
|
|
308
347
|
cataloguedFields.push({
|
|
309
|
-
|
|
348
|
+
...projectFieldDecl(field),
|
|
310
349
|
scope: field.scope,
|
|
311
350
|
targetEntity: field.targetEntity,
|
|
312
|
-
type: field.type,
|
|
313
|
-
name: field.name,
|
|
314
|
-
description: field.description,
|
|
315
|
-
options: field.options,
|
|
316
|
-
relationship: field.relationship,
|
|
317
|
-
calc: field.calc,
|
|
318
|
-
capabilities: field.capabilities,
|
|
319
|
-
identity: field.identity,
|
|
320
351
|
});
|
|
321
352
|
}
|
|
353
|
+
const cataloguedEntities = [];
|
|
354
|
+
const entityKeys = new Set(entitiesArr.map((e) => e.key));
|
|
355
|
+
const entityFieldsByKey = new Map();
|
|
356
|
+
for (const entity of entitiesArr) {
|
|
357
|
+
if (!entity?.key) {
|
|
358
|
+
return errored({ code: 'CATALOG_VALIDATION_FAILED', message: 'Entity is missing a key' });
|
|
359
|
+
}
|
|
360
|
+
const fieldMap = new Map();
|
|
361
|
+
for (const field of entity.fields ?? []) {
|
|
362
|
+
fieldMap.set(field.key, field);
|
|
363
|
+
if (field.type === 'RELATIONSHIP' &&
|
|
364
|
+
field.relationship &&
|
|
365
|
+
'entityKey' in field.relationship.target) {
|
|
366
|
+
const targetKey = field.relationship.target.entityKey;
|
|
367
|
+
if (!entityKeys.has(targetKey)) {
|
|
368
|
+
return errored({
|
|
369
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
370
|
+
message: `Entity "${entity.key}" field "${field.key}": relationship target entityKey "${targetKey}" is not a declared entity`,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
entityFieldsByKey.set(entity.key, fieldMap);
|
|
376
|
+
cataloguedEntities.push({
|
|
377
|
+
key: entity.key,
|
|
378
|
+
apiSlug: entity.apiSlug,
|
|
379
|
+
singular: entity.singular,
|
|
380
|
+
plural: entity.plural,
|
|
381
|
+
description: entity.description,
|
|
382
|
+
icon: entity.icon,
|
|
383
|
+
color: entity.color,
|
|
384
|
+
primaryDisplayField: entity.primaryDisplayField,
|
|
385
|
+
secondaryDisplayField: entity.secondaryDisplayField,
|
|
386
|
+
avatarField: entity.avatarField,
|
|
387
|
+
fields: (entity.fields ?? []).map(projectFieldDecl),
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
for (const field of fieldsArr) {
|
|
391
|
+
if (field.type !== 'RELATIONSHIP' || !field.relationship)
|
|
392
|
+
continue;
|
|
393
|
+
if (!('entityKey' in field.relationship.target))
|
|
394
|
+
continue;
|
|
395
|
+
const targetKey = field.relationship.target.entityKey;
|
|
396
|
+
if (!entityKeys.has(targetKey)) {
|
|
397
|
+
return errored({
|
|
398
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
399
|
+
message: `Field "${field.key}": relationship target entityKey "${targetKey}" is not a declared entity`,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
322
403
|
const cataloguedDataConnectors = [];
|
|
323
404
|
const seenConnectorIds = new Set();
|
|
324
405
|
for (const connector of dataConnectorsArr) {
|
|
@@ -355,60 +436,121 @@ export async function compileAndExtractCatalog() {
|
|
|
355
436
|
});
|
|
356
437
|
}
|
|
357
438
|
}
|
|
439
|
+
const streams = [];
|
|
358
440
|
for (const stream of connector.streams ?? []) {
|
|
359
|
-
|
|
360
|
-
|
|
441
|
+
const mappings = [];
|
|
442
|
+
for (const mapping of stream.mappings ?? []) {
|
|
443
|
+
const context = `Connector "${connector.id}" stream "${stream.key}" mapping "${mapping.rootPath}"`;
|
|
444
|
+
if ('entityKey' in mapping.target) {
|
|
445
|
+
const entityKey = mapping.target.entityKey;
|
|
446
|
+
const fieldMap = entityFieldsByKey.get(entityKey);
|
|
447
|
+
if (!fieldMap) {
|
|
448
|
+
return errored({
|
|
449
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
450
|
+
message: `${context}: unknown entityKey "${entityKey}" — not a declared entity`,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
const normalizedFields = [];
|
|
454
|
+
const ownedFields = (mapping.fields ?? []);
|
|
455
|
+
for (const field of ownedFields) {
|
|
456
|
+
const entityField = fieldMap.get(field.key);
|
|
457
|
+
if (!entityField) {
|
|
458
|
+
return errored({
|
|
459
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
460
|
+
message: `${context}: owned field key "${field.key}" is not declared on entity "${entityKey}"`,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
normalizedFields.push({
|
|
464
|
+
...projectFieldDecl(entityField),
|
|
465
|
+
sourcePath: field.sourcePath,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
mappings.push({
|
|
469
|
+
rootPath: mapping.rootPath,
|
|
470
|
+
parentRootPath: mapping.parentRootPath,
|
|
471
|
+
linkMode: mapping.linkMode,
|
|
472
|
+
relationshipFieldKey: mapping.relationshipFieldKey,
|
|
473
|
+
target: { entityKey },
|
|
474
|
+
...(mapping.fields ? { fields: normalizedFields } : {}),
|
|
475
|
+
});
|
|
361
476
|
continue;
|
|
362
|
-
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
for (const
|
|
367
|
-
if (
|
|
368
|
-
continue;
|
|
369
|
-
if (!fieldByKey.has(binding.targetAppField)) {
|
|
477
|
+
}
|
|
478
|
+
const entityKind = mapping.target.entityKind;
|
|
479
|
+
const fieldByKey = new Map(cataloguedFields.filter((f) => f.targetEntity === entityKind).map((f) => [f.key, f]));
|
|
480
|
+
const contributingFields = (mapping.fields ?? []);
|
|
481
|
+
for (const field of contributingFields) {
|
|
482
|
+
if (field.target && RESERVED_SYSTEM_ATTRIBUTES.has(field.target)) {
|
|
370
483
|
return errored({
|
|
371
484
|
code: 'CATALOG_VALIDATION_FAILED',
|
|
372
|
-
message:
|
|
485
|
+
message: `${context}: target "${field.target}" is a reserved system attribute and cannot be bound by a contributing field`,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
if (field.appField && !fieldByKey.has(field.appField)) {
|
|
489
|
+
return errored({
|
|
490
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
491
|
+
message: `${context}: appField "${field.appField}" is not a declared field on "${entityKind}"`,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
if (field.constant !== undefined) {
|
|
495
|
+
if (field.sourcePath) {
|
|
496
|
+
return errored({
|
|
497
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
498
|
+
message: `${context}: field with constant ${JSON.stringify(field.constant)} cannot also set a sourcePath`,
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
if (!field.target || field.appField) {
|
|
502
|
+
return errored({
|
|
503
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
504
|
+
message: `${context}: a constant field needs a target and cannot set appField`,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
if (field.match) {
|
|
508
|
+
return errored({
|
|
509
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
510
|
+
message: `${context}: constant field "${field.target}" cannot be a match key, the value is identical on every record`,
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else if (!field.sourcePath) {
|
|
515
|
+
return errored({
|
|
516
|
+
code: 'CATALOG_VALIDATION_FAILED',
|
|
517
|
+
message: `${context}: every contributing field needs a sourcePath or a constant`,
|
|
373
518
|
});
|
|
374
519
|
}
|
|
375
520
|
}
|
|
376
|
-
for (const conn of
|
|
377
|
-
const field = fieldByKey.get(conn.
|
|
521
|
+
for (const conn of mapping.connectionFields ?? []) {
|
|
522
|
+
const field = fieldByKey.get(conn.appField);
|
|
378
523
|
if (!field) {
|
|
379
524
|
return errored({
|
|
380
525
|
code: 'CATALOG_VALIDATION_FAILED',
|
|
381
|
-
message:
|
|
526
|
+
message: `${context}: connectionFields "${conn.appField}" is not a declared field on "${entityKind}"`,
|
|
382
527
|
});
|
|
383
528
|
}
|
|
384
529
|
if (field.identity) {
|
|
385
530
|
return errored({
|
|
386
531
|
code: 'CATALOG_VALIDATION_FAILED',
|
|
387
|
-
message:
|
|
532
|
+
message: `${context}: connectionFields "${conn.appField}" targets an identity field — connection metadata cannot fill an identity field`,
|
|
388
533
|
});
|
|
389
534
|
}
|
|
390
535
|
}
|
|
536
|
+
mappings.push({
|
|
537
|
+
rootPath: mapping.rootPath,
|
|
538
|
+
parentRootPath: mapping.parentRootPath,
|
|
539
|
+
linkMode: mapping.linkMode,
|
|
540
|
+
relationshipFieldKey: mapping.relationshipFieldKey,
|
|
541
|
+
target: { entityKind },
|
|
542
|
+
fields: mapping.fields,
|
|
543
|
+
connectionFields: mapping.connectionFields,
|
|
544
|
+
});
|
|
391
545
|
}
|
|
546
|
+
streams.push({
|
|
547
|
+
key: stream.key,
|
|
548
|
+
syncMode: stream.syncMode,
|
|
549
|
+
mappings,
|
|
550
|
+
exampleRecord: stream.exampleRecord,
|
|
551
|
+
webhookTrigger: stream.webhookTrigger,
|
|
552
|
+
});
|
|
392
553
|
}
|
|
393
|
-
const streams = (connector.streams ?? []).map((stream) => ({
|
|
394
|
-
key: stream.key,
|
|
395
|
-
displayFieldKey: stream.displayFieldKey,
|
|
396
|
-
syncMode: stream.syncMode,
|
|
397
|
-
fields: Object.entries(stream.fields ?? {}).map(([fieldKey, decl]) => ({
|
|
398
|
-
fieldKey,
|
|
399
|
-
sourcePath: decl.sourcePath,
|
|
400
|
-
type: decl.type,
|
|
401
|
-
name: decl.name,
|
|
402
|
-
pii: decl.pii,
|
|
403
|
-
capabilities: decl.capabilities,
|
|
404
|
-
options: decl.options,
|
|
405
|
-
addressComponents: decl.addressComponents,
|
|
406
|
-
isExternalId: decl.isExternalId,
|
|
407
|
-
})),
|
|
408
|
-
defaultMappings: stream.defaultMappings,
|
|
409
|
-
exampleRecord: stream.exampleRecord,
|
|
410
|
-
webhookTrigger: stream.webhookTrigger,
|
|
411
|
-
}));
|
|
412
554
|
cataloguedDataConnectors.push({
|
|
413
555
|
id: connector.id,
|
|
414
556
|
label: connector.label,
|
|
@@ -441,6 +583,7 @@ export async function compileAndExtractCatalog() {
|
|
|
441
583
|
},
|
|
442
584
|
actions: cataloguedActions,
|
|
443
585
|
fields: cataloguedFields,
|
|
586
|
+
entities: cataloguedEntities,
|
|
444
587
|
dataConnectors: cataloguedDataConnectors,
|
|
445
588
|
events: eventIds,
|
|
446
589
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auxx/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "CLI tool and SDK for creating Auxx apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./lib/root/fields/index.d.ts",
|
|
47
47
|
"import": "./lib/root/fields/index.js"
|
|
48
48
|
},
|
|
49
|
+
"./entities": {
|
|
50
|
+
"types": "./lib/root/entities/index.d.ts",
|
|
51
|
+
"import": "./lib/root/entities/index.js"
|
|
52
|
+
},
|
|
49
53
|
"./data-connectors": {
|
|
50
54
|
"types": "./lib/root/data-connectors/index.d.ts",
|
|
51
55
|
"import": "./lib/root/data-connectors/index.js"
|