@rippling/rippling-sdk 0.2.0-alpha.108 → 0.2.0-alpha.110
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/client.d.mts +14 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +14 -0
- package/client.d.ts.map +1 -1
- package/client.js +18 -0
- package/client.js.map +1 -1
- package/client.mjs +18 -0
- package/client.mjs.map +1 -1
- package/index.d.mts +5 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -1
- package/index.js +11 -1
- package/index.js.map +1 -1
- package/index.mjs +5 -0
- package/index.mjs.map +1 -1
- package/lib/charts/builders.d.mts +18 -19
- package/lib/charts/builders.d.mts.map +1 -1
- package/lib/charts/builders.d.ts +18 -19
- package/lib/charts/builders.d.ts.map +1 -1
- package/lib/charts/builders.js +35 -28
- package/lib/charts/builders.js.map +1 -1
- package/lib/charts/builders.mjs +35 -28
- package/lib/charts/builders.mjs.map +1 -1
- package/lib/charts/describe.d.mts +6 -7
- package/lib/charts/describe.d.mts.map +1 -1
- package/lib/charts/describe.d.ts +6 -7
- package/lib/charts/describe.d.ts.map +1 -1
- package/lib/charts/describe.js +26 -27
- package/lib/charts/describe.js.map +1 -1
- package/lib/charts/describe.mjs +27 -28
- package/lib/charts/describe.mjs.map +1 -1
- package/lib/charts/errors.d.mts +2 -6
- package/lib/charts/errors.d.mts.map +1 -1
- package/lib/charts/errors.d.ts +2 -6
- package/lib/charts/errors.d.ts.map +1 -1
- package/lib/charts/errors.js +2 -6
- package/lib/charts/errors.js.map +1 -1
- package/lib/charts/errors.mjs +2 -6
- package/lib/charts/errors.mjs.map +1 -1
- package/lib/charts/evaluate.d.mts +5 -7
- package/lib/charts/evaluate.d.mts.map +1 -1
- package/lib/charts/evaluate.d.ts +5 -7
- package/lib/charts/evaluate.d.ts.map +1 -1
- package/lib/charts/evaluate.js +21 -35
- package/lib/charts/evaluate.js.map +1 -1
- package/lib/charts/evaluate.mjs +22 -36
- package/lib/charts/evaluate.mjs.map +1 -1
- package/lib/charts/schema.d.mts +8 -97
- package/lib/charts/schema.d.mts.map +1 -1
- package/lib/charts/schema.d.ts +8 -97
- package/lib/charts/schema.d.ts.map +1 -1
- package/lib/charts/schema.js +186 -65
- package/lib/charts/schema.js.map +1 -1
- package/lib/charts/schema.mjs +185 -65
- package/lib/charts/schema.mjs.map +1 -1
- package/lib/charts/types.d.mts +40 -25
- package/lib/charts/types.d.mts.map +1 -1
- package/lib/charts/types.d.ts +40 -25
- package/lib/charts/types.d.ts.map +1 -1
- package/lib/charts/types.js +8 -10
- package/lib/charts/types.js.map +1 -1
- package/lib/charts/types.mjs +8 -10
- package/lib/charts/types.mjs.map +1 -1
- package/lib/charts/visualization-grammar.d.mts +66 -0
- package/lib/charts/visualization-grammar.d.mts.map +1 -0
- package/lib/charts/visualization-grammar.d.ts +66 -0
- package/lib/charts/visualization-grammar.d.ts.map +1 -0
- package/lib/charts/visualization-grammar.js +70 -0
- package/lib/charts/visualization-grammar.js.map +1 -0
- package/lib/charts/visualization-grammar.mjs +67 -0
- package/lib/charts/visualization-grammar.mjs.map +1 -0
- package/lib/charts/vocabulary.d.mts +7 -0
- package/lib/charts/vocabulary.d.mts.map +1 -0
- package/lib/charts/vocabulary.d.ts +7 -0
- package/lib/charts/vocabulary.d.ts.map +1 -0
- package/lib/charts/vocabulary.js +10 -0
- package/lib/charts/vocabulary.js.map +1 -0
- package/lib/charts/vocabulary.mjs +7 -0
- package/lib/charts/vocabulary.mjs.map +1 -0
- package/lib/charts.d.mts +3 -3
- package/lib/charts.d.mts.map +1 -1
- package/lib/charts.d.ts +3 -3
- package/lib/charts.d.ts.map +1 -1
- package/lib/charts.js +2 -1
- package/lib/charts.js.map +1 -1
- package/lib/charts.mjs +1 -1
- package/lib/charts.mjs.map +1 -1
- package/lib/manifest/composition.d.mts +21 -0
- package/lib/manifest/composition.d.mts.map +1 -0
- package/lib/manifest/composition.d.ts +21 -0
- package/lib/manifest/composition.d.ts.map +1 -0
- package/lib/manifest/composition.js +103 -0
- package/lib/manifest/composition.js.map +1 -0
- package/lib/manifest/composition.mjs +99 -0
- package/lib/manifest/composition.mjs.map +1 -0
- package/lib/manifest/definitions/_object-records.d.mts +23 -0
- package/lib/manifest/definitions/_object-records.d.mts.map +1 -0
- package/lib/manifest/definitions/_object-records.d.ts +23 -0
- package/lib/manifest/definitions/_object-records.d.ts.map +1 -0
- package/lib/manifest/definitions/_object-records.js +151 -0
- package/lib/manifest/definitions/_object-records.js.map +1 -0
- package/lib/manifest/definitions/_object-records.mjs +147 -0
- package/lib/manifest/definitions/_object-records.mjs.map +1 -0
- package/lib/manifest/definitions/action.d.mts +7 -0
- package/lib/manifest/definitions/action.d.mts.map +1 -0
- package/lib/manifest/definitions/action.d.ts +7 -0
- package/lib/manifest/definitions/action.d.ts.map +1 -0
- package/lib/manifest/definitions/action.js +25 -0
- package/lib/manifest/definitions/action.js.map +1 -0
- package/lib/manifest/definitions/action.mjs +22 -0
- package/lib/manifest/definitions/action.mjs.map +1 -0
- package/lib/manifest/definitions/agent.d.mts +51 -0
- package/lib/manifest/definitions/agent.d.mts.map +1 -0
- package/lib/manifest/definitions/agent.d.ts +51 -0
- package/lib/manifest/definitions/agent.d.ts.map +1 -0
- package/lib/manifest/definitions/agent.js +65 -0
- package/lib/manifest/definitions/agent.js.map +1 -0
- package/lib/manifest/definitions/agent.mjs +59 -0
- package/lib/manifest/definitions/agent.mjs.map +1 -0
- package/lib/manifest/definitions/app.d.mts +3 -0
- package/lib/manifest/definitions/app.d.mts.map +1 -0
- package/lib/manifest/definitions/app.d.ts +3 -0
- package/lib/manifest/definitions/app.d.ts.map +1 -0
- package/lib/manifest/definitions/app.js +14 -0
- package/lib/manifest/definitions/app.js.map +1 -0
- package/lib/manifest/definitions/app.mjs +11 -0
- package/lib/manifest/definitions/app.mjs.map +1 -0
- package/lib/manifest/definitions/category.d.mts +9 -0
- package/lib/manifest/definitions/category.d.mts.map +1 -0
- package/lib/manifest/definitions/category.d.ts +9 -0
- package/lib/manifest/definitions/category.d.ts.map +1 -0
- package/lib/manifest/definitions/category.js +27 -0
- package/lib/manifest/definitions/category.js.map +1 -0
- package/lib/manifest/definitions/category.mjs +23 -0
- package/lib/manifest/definitions/category.mjs.map +1 -0
- package/lib/manifest/definitions/component.d.mts +101 -0
- package/lib/manifest/definitions/component.d.mts.map +1 -0
- package/lib/manifest/definitions/component.d.ts +101 -0
- package/lib/manifest/definitions/component.d.ts.map +1 -0
- package/lib/manifest/definitions/component.js +106 -0
- package/lib/manifest/definitions/component.js.map +1 -0
- package/lib/manifest/definitions/component.mjs +97 -0
- package/lib/manifest/definitions/component.mjs.map +1 -0
- package/lib/manifest/definitions/custom-field-section.d.mts +13 -0
- package/lib/manifest/definitions/custom-field-section.d.mts.map +1 -0
- package/lib/manifest/definitions/custom-field-section.d.ts +13 -0
- package/lib/manifest/definitions/custom-field-section.d.ts.map +1 -0
- package/lib/manifest/definitions/custom-field-section.js +15 -0
- package/lib/manifest/definitions/custom-field-section.js.map +1 -0
- package/lib/manifest/definitions/custom-field-section.mjs +12 -0
- package/lib/manifest/definitions/custom-field-section.mjs.map +1 -0
- package/lib/manifest/definitions/custom-field.d.mts +10 -0
- package/lib/manifest/definitions/custom-field.d.mts.map +1 -0
- package/lib/manifest/definitions/custom-field.d.ts +10 -0
- package/lib/manifest/definitions/custom-field.d.ts.map +1 -0
- package/lib/manifest/definitions/custom-field.js +18 -0
- package/lib/manifest/definitions/custom-field.js.map +1 -0
- package/lib/manifest/definitions/custom-field.mjs +15 -0
- package/lib/manifest/definitions/custom-field.mjs.map +1 -0
- package/lib/manifest/definitions/custom-object.d.mts +162 -0
- package/lib/manifest/definitions/custom-object.d.mts.map +1 -0
- package/lib/manifest/definitions/custom-object.d.ts +162 -0
- package/lib/manifest/definitions/custom-object.d.ts.map +1 -0
- package/lib/manifest/definitions/custom-object.js +412 -0
- package/lib/manifest/definitions/custom-object.js.map +1 -0
- package/lib/manifest/definitions/custom-object.mjs +386 -0
- package/lib/manifest/definitions/custom-object.mjs.map +1 -0
- package/lib/manifest/definitions/custom-skill.d.mts +8 -0
- package/lib/manifest/definitions/custom-skill.d.mts.map +1 -0
- package/lib/manifest/definitions/custom-skill.d.ts +8 -0
- package/lib/manifest/definitions/custom-skill.d.ts.map +1 -0
- package/lib/manifest/definitions/custom-skill.js +15 -0
- package/lib/manifest/definitions/custom-skill.js.map +1 -0
- package/lib/manifest/definitions/custom-skill.mjs +12 -0
- package/lib/manifest/definitions/custom-skill.mjs.map +1 -0
- package/lib/manifest/definitions/field-section.d.mts +7 -0
- package/lib/manifest/definitions/field-section.d.mts.map +1 -0
- package/lib/manifest/definitions/field-section.d.ts +7 -0
- package/lib/manifest/definitions/field-section.d.ts.map +1 -0
- package/lib/manifest/definitions/field-section.js +16 -0
- package/lib/manifest/definitions/field-section.js.map +1 -0
- package/lib/manifest/definitions/field-section.mjs +13 -0
- package/lib/manifest/definitions/field-section.mjs.map +1 -0
- package/lib/manifest/definitions/field.d.mts +38 -0
- package/lib/manifest/definitions/field.d.mts.map +1 -0
- package/lib/manifest/definitions/field.d.ts +38 -0
- package/lib/manifest/definitions/field.d.ts.map +1 -0
- package/lib/manifest/definitions/field.js +50 -0
- package/lib/manifest/definitions/field.js.map +1 -0
- package/lib/manifest/definitions/field.mjs +45 -0
- package/lib/manifest/definitions/field.mjs.map +1 -0
- package/lib/manifest/definitions/function.d.mts +61 -0
- package/lib/manifest/definitions/function.d.mts.map +1 -0
- package/lib/manifest/definitions/function.d.ts +61 -0
- package/lib/manifest/definitions/function.d.ts.map +1 -0
- package/lib/manifest/definitions/function.js +79 -0
- package/lib/manifest/definitions/function.js.map +1 -0
- package/lib/manifest/definitions/function.mjs +73 -0
- package/lib/manifest/definitions/function.mjs.map +1 -0
- package/lib/manifest/definitions/index.d.mts +22 -0
- package/lib/manifest/definitions/index.d.mts.map +1 -0
- package/lib/manifest/definitions/index.d.ts +22 -0
- package/lib/manifest/definitions/index.d.ts.map +1 -0
- package/lib/manifest/definitions/index.js +64 -0
- package/lib/manifest/definitions/index.js.map +1 -0
- package/lib/manifest/definitions/index.mjs +22 -0
- package/lib/manifest/definitions/index.mjs.map +1 -0
- package/lib/manifest/definitions/list-view.d.mts +9 -0
- package/lib/manifest/definitions/list-view.d.mts.map +1 -0
- package/lib/manifest/definitions/list-view.d.ts +9 -0
- package/lib/manifest/definitions/list-view.d.ts.map +1 -0
- package/lib/manifest/definitions/list-view.js +25 -0
- package/lib/manifest/definitions/list-view.js.map +1 -0
- package/lib/manifest/definitions/list-view.mjs +22 -0
- package/lib/manifest/definitions/list-view.mjs.map +1 -0
- package/lib/manifest/definitions/object-search-config.d.mts +13 -0
- package/lib/manifest/definitions/object-search-config.d.mts.map +1 -0
- package/lib/manifest/definitions/object-search-config.d.ts +13 -0
- package/lib/manifest/definitions/object-search-config.d.ts.map +1 -0
- package/lib/manifest/definitions/object-search-config.js +25 -0
- package/lib/manifest/definitions/object-search-config.js.map +1 -0
- package/lib/manifest/definitions/object-search-config.mjs +22 -0
- package/lib/manifest/definitions/object-search-config.mjs.map +1 -0
- package/lib/manifest/definitions/object-settings.d.mts +24 -0
- package/lib/manifest/definitions/object-settings.d.mts.map +1 -0
- package/lib/manifest/definitions/object-settings.d.ts +24 -0
- package/lib/manifest/definitions/object-settings.d.ts.map +1 -0
- package/lib/manifest/definitions/object-settings.js +32 -0
- package/lib/manifest/definitions/object-settings.js.map +1 -0
- package/lib/manifest/definitions/object-settings.mjs +29 -0
- package/lib/manifest/definitions/object-settings.mjs.map +1 -0
- package/lib/manifest/definitions/page-layout.d.mts +21 -0
- package/lib/manifest/definitions/page-layout.d.mts.map +1 -0
- package/lib/manifest/definitions/page-layout.d.ts +21 -0
- package/lib/manifest/definitions/page-layout.d.ts.map +1 -0
- package/lib/manifest/definitions/page-layout.js +155 -0
- package/lib/manifest/definitions/page-layout.js.map +1 -0
- package/lib/manifest/definitions/page-layout.mjs +152 -0
- package/lib/manifest/definitions/page-layout.mjs.map +1 -0
- package/lib/manifest/definitions/page.d.mts +8 -0
- package/lib/manifest/definitions/page.d.mts.map +1 -0
- package/lib/manifest/definitions/page.d.ts +8 -0
- package/lib/manifest/definitions/page.d.ts.map +1 -0
- package/lib/manifest/definitions/page.js +15 -0
- package/lib/manifest/definitions/page.js.map +1 -0
- package/lib/manifest/definitions/page.mjs +12 -0
- package/lib/manifest/definitions/page.mjs.map +1 -0
- package/lib/manifest/definitions/record-triggered-flow.d.mts +24 -0
- package/lib/manifest/definitions/record-triggered-flow.d.mts.map +1 -0
- package/lib/manifest/definitions/record-triggered-flow.d.ts +24 -0
- package/lib/manifest/definitions/record-triggered-flow.d.ts.map +1 -0
- package/lib/manifest/definitions/record-triggered-flow.js +28 -0
- package/lib/manifest/definitions/record-triggered-flow.js.map +1 -0
- package/lib/manifest/definitions/record-triggered-flow.mjs +25 -0
- package/lib/manifest/definitions/record-triggered-flow.mjs.map +1 -0
- package/lib/manifest/definitions/validation.d.mts +8 -0
- package/lib/manifest/definitions/validation.d.mts.map +1 -0
- package/lib/manifest/definitions/validation.d.ts +8 -0
- package/lib/manifest/definitions/validation.d.ts.map +1 -0
- package/lib/manifest/definitions/validation.js +24 -0
- package/lib/manifest/definitions/validation.js.map +1 -0
- package/lib/manifest/definitions/validation.mjs +21 -0
- package/lib/manifest/definitions/validation.mjs.map +1 -0
- package/lib/manifest/definitions/workflow.d.mts +10 -0
- package/lib/manifest/definitions/workflow.d.mts.map +1 -0
- package/lib/manifest/definitions/workflow.d.ts +10 -0
- package/lib/manifest/definitions/workflow.d.ts.map +1 -0
- package/lib/manifest/definitions/workflow.js +33 -0
- package/lib/manifest/definitions/workflow.js.map +1 -0
- package/lib/manifest/definitions/workflow.mjs +29 -0
- package/lib/manifest/definitions/workflow.mjs.map +1 -0
- package/lib/manifest/index.d.mts +3 -0
- package/lib/manifest/index.d.mts.map +1 -1
- package/lib/manifest/index.d.ts +3 -0
- package/lib/manifest/index.d.ts.map +1 -1
- package/lib/manifest/index.js +4 -0
- package/lib/manifest/index.js.map +1 -1
- package/lib/manifest/index.mjs +3 -0
- package/lib/manifest/index.mjs.map +1 -1
- package/lib/manifest/package-manifest.d.mts +17 -0
- package/lib/manifest/package-manifest.d.mts.map +1 -0
- package/lib/manifest/package-manifest.d.ts +17 -0
- package/lib/manifest/package-manifest.d.ts.map +1 -0
- package/lib/manifest/package-manifest.js +26 -0
- package/lib/manifest/package-manifest.js.map +1 -0
- package/lib/manifest/package-manifest.mjs +23 -0
- package/lib/manifest/package-manifest.mjs.map +1 -0
- package/package.json +4 -2
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/reimbursements.d.mts +1 -1
- package/resources/reimbursements.d.ts +1 -1
- package/resources/reimbursements.js +1 -1
- package/resources/reimbursements.mjs +1 -1
- package/resources/spend-categories.d.mts +140 -0
- package/resources/spend-categories.d.mts.map +1 -0
- package/resources/spend-categories.d.ts +140 -0
- package/resources/spend-categories.d.ts.map +1 -0
- package/resources/spend-categories.js +83 -0
- package/resources/spend-categories.js.map +1 -0
- package/resources/spend-categories.mjs +79 -0
- package/resources/spend-categories.mjs.map +1 -0
- package/src/client.ts +41 -0
- package/src/index.ts +17 -0
- package/src/lib/charts/README.md +35 -28
- package/src/lib/charts/agent-reference.md +73 -0
- package/src/lib/charts/builders.ts +51 -35
- package/src/lib/charts/capabilities.json +96 -0
- package/src/lib/charts/describe.ts +31 -29
- package/src/lib/charts/errors.ts +2 -6
- package/src/lib/charts/evaluate.ts +25 -38
- package/src/lib/charts/schema.ts +232 -66
- package/src/lib/charts/types.ts +42 -31
- package/src/lib/charts/visualization-grammar.ts +67 -0
- package/src/lib/charts/vocabulary.ts +7 -0
- package/src/lib/charts.ts +8 -1
- package/src/lib/manifest/composition.ts +133 -0
- package/src/lib/manifest/definitions/README.md +89 -0
- package/src/lib/manifest/definitions/_object-records.ts +218 -0
- package/src/lib/manifest/definitions/action.ts +31 -0
- package/src/lib/manifest/definitions/agent.ts +149 -0
- package/src/lib/manifest/definitions/app.ts +12 -0
- package/src/lib/manifest/definitions/category.ts +35 -0
- package/src/lib/manifest/definitions/component.ts +241 -0
- package/src/lib/manifest/definitions/custom-field-section.ts +39 -0
- package/src/lib/manifest/definitions/custom-field.ts +32 -0
- package/src/lib/manifest/definitions/custom-object.ts +786 -0
- package/src/lib/manifest/definitions/custom-skill.ts +28 -0
- package/src/lib/manifest/definitions/field-section.ts +31 -0
- package/src/lib/manifest/definitions/field.ts +119 -0
- package/src/lib/manifest/definitions/function.ts +198 -0
- package/src/lib/manifest/definitions/index.ts +91 -0
- package/src/lib/manifest/definitions/list-view.ts +48 -0
- package/src/lib/manifest/definitions/object-search-config.ts +44 -0
- package/src/lib/manifest/definitions/object-settings.ts +61 -0
- package/src/lib/manifest/definitions/page-layout.ts +218 -0
- package/src/lib/manifest/definitions/page.ts +28 -0
- package/src/lib/manifest/definitions/record-triggered-flow.ts +71 -0
- package/src/lib/manifest/definitions/validation.ts +46 -0
- package/src/lib/manifest/definitions/workflow.ts +62 -0
- package/src/lib/manifest/index.ts +4 -0
- package/src/lib/manifest/package-manifest.ts +40 -0
- package/src/resources/index.ts +7 -0
- package/src/resources/reimbursements.ts +1 -1
- package/src/resources/spend-categories.ts +175 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/lib/charts/guards.d.mts +0 -15
- package/lib/charts/guards.d.mts.map +0 -1
- package/lib/charts/guards.d.ts +0 -15
- package/lib/charts/guards.d.ts.map +0 -1
- package/lib/charts/guards.js +0 -38
- package/lib/charts/guards.js.map +0 -1
- package/lib/charts/guards.mjs +0 -34
- package/lib/charts/guards.mjs.map +0 -1
- package/src/lib/charts/guards.ts +0 -42
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Component definitions
|
|
2
|
+
|
|
3
|
+
`defineX` helpers create reusable metadata definitions. Objects, functions, and ACP agents also expose runtime operations that accept an authenticated client per call.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
RipplingSDK,
|
|
10
|
+
defineCustomObject,
|
|
11
|
+
defineListView,
|
|
12
|
+
defineManifest,
|
|
13
|
+
fields,
|
|
14
|
+
eq,
|
|
15
|
+
} from '@rippling/rippling-sdk';
|
|
16
|
+
|
|
17
|
+
export const Ticket = defineCustomObject({
|
|
18
|
+
apiName: 'ticket__c',
|
|
19
|
+
name: 'Ticket',
|
|
20
|
+
description: 'Support tickets',
|
|
21
|
+
fields: { title__c: fields.text({ label: 'Title' }) },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Tickets = defineListView(Ticket, {
|
|
25
|
+
apiName: 'all_tickets__c',
|
|
26
|
+
name: 'All tickets',
|
|
27
|
+
description: 'Support tickets',
|
|
28
|
+
fields: [Ticket.fields.title__c],
|
|
29
|
+
isPublic: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default defineManifest({ components: [Ticket, Tickets] });
|
|
33
|
+
|
|
34
|
+
Ticket.apiName;
|
|
35
|
+
Ticket.fields.title__c;
|
|
36
|
+
|
|
37
|
+
const client = new RipplingSDK({ bearerToken: 'YOUR_TOKEN' });
|
|
38
|
+
await Ticket.records.create(client, { name: 'Bug', title__c: 'Bug' });
|
|
39
|
+
// Equivalent client-helper form:
|
|
40
|
+
await client.objects(Ticket).create({ name: 'Bug', title__c: 'Bug' });
|
|
41
|
+
await Ticket.records.list(client, { where: eq(Ticket.fields.title__c, 'Bug') });
|
|
42
|
+
await Ticket.records.query(client, { query: "(title__c == 'Bug')" });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Definitions retain no credentials and remain reusable manifest inputs with either call style. Constructor-based authoring remains available through `ManifestBuilder`.
|
|
46
|
+
|
|
47
|
+
- Objects expose typed `records` operations and filters such as `eq(Ticket.fields.title__c, 'Bug')`. `Ticket.fields` contains local field tokens; deployed metadata is available through `Ticket.schema.retrieve(client)` and `Ticket.schema.fields.list(client)`.
|
|
48
|
+
- Functions expose `fn.execute(client, input)` and `fn.executions` for listing, retrieval, and logs. `fn.handler(...)` shares the input/output contract. The client-helper form is `client.function(fn)`.
|
|
49
|
+
- ACP agents expose `agent.retrieve(client)` and `agent.sessions.create/list(client, ...)`. The client-helper form is `client.agent(agent)`.
|
|
50
|
+
|
|
51
|
+
Operations reuse generated request options and pagination helpers. TypeScript checks local field values and references; live use also requires backend support for API-name creation and runtime routing.
|
|
52
|
+
|
|
53
|
+
Definition-based record writes accept `null` for optional writable custom fields, including fields declared with `nullable: true`. Required and computed fields retain their write restrictions. Numeric fields and numeric formulas decode API decimal strings to JavaScript numbers, with JavaScript's usual floating-point precision.
|
|
54
|
+
|
|
55
|
+
## Composition and source files
|
|
56
|
+
|
|
57
|
+
`defineManifest` collects dependencies declared by the component's `references` hook, such as an app's pages and their rendering functions. Include other desired children as roots: listing an object does not include every view or action created for it. Raw strings and opaque JSON do not create dependencies.
|
|
58
|
+
|
|
59
|
+
New custom objects require at least one list view, including objects included through lookup dependencies. Add their views as explicit roots.
|
|
60
|
+
|
|
61
|
+
Composition snapshots the existing `{ metadata, components }` wire format. Identical serialized keys are deduplicated; different configs with the same key are rejected. Fields and layouts use object-scoped names; native fields and sections use model-scoped names. Custom-object sections, actions, views, validations, and record-triggered flows require names unique across objects because their backend lookups or installation maps are company-scoped. Authored metadata replaces generated defaults, and base/extended objects share generated layouts.
|
|
62
|
+
|
|
63
|
+
Supply complete API names: objects, categories, nested field and section keys, actions, validations, record-triggered flows, workflows, pages, custom skills, and ACP agents require `__c`. The helpers validate names rather than adding suffixes. Category string references also use the complete API name. Native sections require `__cfs`; native fields require `__cfv2`. Employee custom fields use `applicableGroupId` for an existing applicability group. Owner permissions are created by the backend when it installs the object.
|
|
64
|
+
|
|
65
|
+
Definitions with file sources require `compileManifest(manifest, readSource)` or `rippling project export` before JSON serialization. Source files are read only at compilation, unchanged; export does not bundle local imports. `fn.setCode(...)` and `agent.setSource(...)` replace file sources for subsequent manifests. Previously composed manifests keep their source snapshots.
|
|
66
|
+
|
|
67
|
+
`defineCustomSkill` emits its API name as both `api_name` and `source_skill_id`, with `identity_format_version: 2`. Skill references use that API name; legacy constructors keep their source-ID format.
|
|
68
|
+
|
|
69
|
+
## Adding a component
|
|
70
|
+
|
|
71
|
+
Keep each component’s types, construction, serialization, reference handling, and runtime operations in one module using `defineComponent`. Related components reuse the owning module’s helpers:
|
|
72
|
+
|
|
73
|
+
1. Put public input/result types first, followed by a named exported `defineX` function. Keep runtime methods explicit in public interfaces. The factory constructs its result and calls the component adapter’s `register(result, ...arguments)`; a metadata class is optional.
|
|
74
|
+
2. Add `references` when there are local dependencies; it defaults to none. For replaceable references, return a callback reading the current state used by serialization; see [action.ts](./action.ts).
|
|
75
|
+
3. Implement `serialize(definition)` to return its wire config. Existing `toDict()` methods are used automatically when no serializer is supplied. Use `compileBatch(definitions, context)` for schema expansion or merging, as in [custom-object.ts](./custom-object.ts). Return `{ config, fallback: true }` only for generated defaults that should yield to authored metadata.
|
|
76
|
+
4. Export the named factory and public types from [index.ts](./index.ts). Place the `defineComponent({ type, define: defineX, ... })` adapter and private serialization/reference helpers below the public API.
|
|
77
|
+
|
|
78
|
+
Use these existing implementations as references:
|
|
79
|
+
|
|
80
|
+
- [app.ts](./app.ts): minimal registration reusing a metadata class and serializer. `detachedManifestScope` keeps constructor effects separate from legacy builders.
|
|
81
|
+
- [object-settings.ts](./object-settings.ts): a definition without a metadata class, with its own fields and serialization.
|
|
82
|
+
- [function.ts](./function.ts) and [custom-object.ts](./custom-object.ts): runtime methods taking a structural authenticated context. Add any client accessor in [client.ts](../../../client.ts) by forwarding to the same operations.
|
|
83
|
+
- [component.ts](./component.ts): wire config types, serialized key extraction, and `sourceEntry` for deferred file loading. Add a new kind to `ComponentType` here or `ManifestComponentType` in [manifest-builder.ts](../manifest-builder.ts), and define its identifying wire fields in `MetadataConfig`. Scoped or singleton kinds also need an `entryKey` case.
|
|
84
|
+
|
|
85
|
+
Component implementations own serialization; there is no separate identity declaration. Runtime methods and client accessors are explicit implementations, not generated by `defineComponent`. New metadata kinds and operations require corresponding backend contracts.
|
|
86
|
+
|
|
87
|
+
Verify wire output, dependencies, scoped conflicts, and public types. For mutable definitions, check that subsequent manifests use current references while prior snapshots remain unchanged. Runtime checks should cover the endpoint contract and pagination where applicable.
|
|
88
|
+
|
|
89
|
+
Run `yarn test --runInBand` and `yarn lint`.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCustomObjectRecordAdapter,
|
|
3
|
+
CustomObjectRecordValidationError,
|
|
4
|
+
} from '../../../core/platform/custom-objects/manager';
|
|
5
|
+
import {
|
|
6
|
+
validateCreateInput,
|
|
7
|
+
validateUpdateInput,
|
|
8
|
+
type ValidationIssue,
|
|
9
|
+
} from '../../../core/platform/custom-objects/validation';
|
|
10
|
+
import type {
|
|
11
|
+
AnyCustomObjectDefinition,
|
|
12
|
+
AnyFieldDefinition,
|
|
13
|
+
CreateInput,
|
|
14
|
+
UpdateInput,
|
|
15
|
+
FieldValue,
|
|
16
|
+
RecordShape,
|
|
17
|
+
} from '../../../core/platform/custom-objects/types';
|
|
18
|
+
import type { CustomObjectDataRow } from '../../../resources/custom-objects/records';
|
|
19
|
+
import type { ObjectRecords, ObjectRecordsContext } from './custom-object';
|
|
20
|
+
|
|
21
|
+
type NullableFields<D extends AnyCustomObjectDefinition> = {
|
|
22
|
+
[K in keyof D['fields']]: D['fields'][K] extends { writable: true; required: false } ? K : never;
|
|
23
|
+
}[keyof D['fields']];
|
|
24
|
+
|
|
25
|
+
/** Definition-based writes accept null for writable, non-required custom fields. */
|
|
26
|
+
export type ObjectCreateInput<D extends AnyCustomObjectDefinition> = Omit<
|
|
27
|
+
CreateInput<D>,
|
|
28
|
+
NullableFields<D>
|
|
29
|
+
> & {
|
|
30
|
+
[K in NullableFields<D>]?: FieldValue<D['fields'][K]> | null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ObjectUpdateInput<D extends AnyCustomObjectDefinition> = Omit<
|
|
34
|
+
UpdateInput<D>,
|
|
35
|
+
NullableFields<D>
|
|
36
|
+
> & {
|
|
37
|
+
[K in NullableFields<D>]?: FieldValue<D['fields'][K]> | null;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type ObjectBulkUpdateInput<D extends AnyCustomObjectDefinition> = {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
} & ObjectUpdateInput<D>;
|
|
43
|
+
|
|
44
|
+
/** Reuse the existing value checks, excluding only explicitly allowed null custom-field values. */
|
|
45
|
+
function inputIssues(
|
|
46
|
+
definition: AnyCustomObjectDefinition,
|
|
47
|
+
input: Record<string, unknown>,
|
|
48
|
+
operation: 'create' | 'update',
|
|
49
|
+
): readonly ValidationIssue[] {
|
|
50
|
+
if (input == null || typeof input !== 'object' || Array.isArray(input))
|
|
51
|
+
return [{ path: '', message: 'Expected a record object.' }];
|
|
52
|
+
const checked = { ...input };
|
|
53
|
+
for (const [key, field] of Object.entries(definition.fields)) {
|
|
54
|
+
if (field.writable && !field.required && checked[key] === null) delete checked[key];
|
|
55
|
+
}
|
|
56
|
+
return (operation === 'create' ? validateCreateInput : validateUpdateInput)(definition, checked).issues;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function assertObjectInput(
|
|
60
|
+
definition: AnyCustomObjectDefinition,
|
|
61
|
+
input: Record<string, unknown>,
|
|
62
|
+
operation: 'create' | 'update',
|
|
63
|
+
): void {
|
|
64
|
+
const issues = inputIssues(definition, input, operation);
|
|
65
|
+
if (issues.length > 0) throw new CustomObjectRecordValidationError(definition, operation, issues);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function referenceID(value: unknown): unknown {
|
|
69
|
+
return value != null && typeof value === 'object' && 'id' in value ? value.id : value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function serializeInput(
|
|
73
|
+
definition: AnyCustomObjectDefinition,
|
|
74
|
+
input: Record<string, unknown>,
|
|
75
|
+
): Record<string, unknown> {
|
|
76
|
+
const wire: Record<string, unknown> = {};
|
|
77
|
+
for (const key of ['name', 'external_id', 'owner_role']) {
|
|
78
|
+
if (Object.prototype.hasOwnProperty.call(input, key) && input[key] !== undefined)
|
|
79
|
+
wire[key] = key === 'owner_role' ? referenceID(input[key]) : input[key];
|
|
80
|
+
}
|
|
81
|
+
for (const [key, field] of Object.entries(definition.fields)) {
|
|
82
|
+
if (!Object.prototype.hasOwnProperty.call(input, key) || input[key] === undefined) continue;
|
|
83
|
+
wire[field.apiName] =
|
|
84
|
+
field.kind === 'lookup' || field.kind === 'parent-child' || field.kind === 'file' ?
|
|
85
|
+
referenceID(input[key])
|
|
86
|
+
: input[key];
|
|
87
|
+
}
|
|
88
|
+
return wire;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function lookup(value: unknown, apiName: string) {
|
|
92
|
+
if (typeof value === 'string') return { id: value, apiName };
|
|
93
|
+
if (value != null && typeof value === 'object' && 'id' in value && typeof value.id === 'string') {
|
|
94
|
+
return {
|
|
95
|
+
id: value.id,
|
|
96
|
+
apiName: 'apiName' in value && typeof value.apiName === 'string' ? value.apiName : apiName,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function fieldValue(field: AnyFieldDefinition, value: unknown): unknown {
|
|
103
|
+
if (value == null) return null;
|
|
104
|
+
switch (field.kind) {
|
|
105
|
+
case 'lookup':
|
|
106
|
+
case 'parent-child':
|
|
107
|
+
return lookup(value, field.targetApiName ?? 'unknown');
|
|
108
|
+
case 'file':
|
|
109
|
+
return (
|
|
110
|
+
typeof value === 'string' ? value
|
|
111
|
+
: value != null && typeof value === 'object' && 'id' in value && typeof value.id === 'string' ?
|
|
112
|
+
{ id: value.id }
|
|
113
|
+
: null
|
|
114
|
+
);
|
|
115
|
+
case 'number':
|
|
116
|
+
case 'currency':
|
|
117
|
+
case 'percentage':
|
|
118
|
+
case 'formula-number':
|
|
119
|
+
case 'formula-currency':
|
|
120
|
+
case 'formula-percentage': {
|
|
121
|
+
const numeric =
|
|
122
|
+
typeof value === 'number' ? value
|
|
123
|
+
: typeof value === 'string' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value) ?
|
|
124
|
+
Number(value)
|
|
125
|
+
: NaN;
|
|
126
|
+
if (!Number.isFinite(numeric))
|
|
127
|
+
throw new TypeError(`Invalid numeric value for ${field.apiName}: expected a finite number.`);
|
|
128
|
+
return numeric;
|
|
129
|
+
}
|
|
130
|
+
default:
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function decodeRecord<D extends AnyCustomObjectDefinition>(
|
|
136
|
+
definition: D,
|
|
137
|
+
row: CustomObjectDataRow,
|
|
138
|
+
): RecordShape<D> {
|
|
139
|
+
const record: Record<string, unknown> = { id: row.id, name: row.name };
|
|
140
|
+
for (const key of ['created_at', 'updated_at', 'system_updated_at', 'external_id'])
|
|
141
|
+
record[key] = typeof row[key] === 'string' ? row[key] : null;
|
|
142
|
+
for (const key of ['owner_role', 'created_by', 'last_modified_by'])
|
|
143
|
+
record[key] = lookup(row[key], 'Employee');
|
|
144
|
+
for (const [key, field] of Object.entries(definition.fields))
|
|
145
|
+
record[key] = fieldValue(field as AnyFieldDefinition, row[field.apiName]);
|
|
146
|
+
return record as RecordShape<D>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Definition-specific nullability and decoding; the shared manager and legacy constructors are unchanged. */
|
|
150
|
+
export function createObjectRecords<D extends AnyCustomObjectDefinition>(
|
|
151
|
+
definition: D,
|
|
152
|
+
): Readonly<ObjectRecords<D>> {
|
|
153
|
+
const adapter = (ctx: ObjectRecordsContext) => createCustomObjectRecordAdapter(ctx.customObjects.records);
|
|
154
|
+
const decode = (row: CustomObjectDataRow) => decodeRecord(definition, row);
|
|
155
|
+
const serializeBatch = (rows: readonly Record<string, unknown>[], operation: 'create' | 'update') => {
|
|
156
|
+
const issues = rows.flatMap((row, index) => {
|
|
157
|
+
if (row == null || typeof row !== 'object' || Array.isArray(row))
|
|
158
|
+
return [{ path: `[${index}]`, message: 'Expected a record object.' }];
|
|
159
|
+
const { id, ...patch } = row;
|
|
160
|
+
return [
|
|
161
|
+
...(operation === 'update' && (typeof id !== 'string' || id.length === 0) ?
|
|
162
|
+
[{ path: `[${index}].id`, message: 'Expected a record id string.' }]
|
|
163
|
+
: []),
|
|
164
|
+
...inputIssues(definition, operation === 'update' ? patch : row, operation).map((issue) => ({
|
|
165
|
+
...issue,
|
|
166
|
+
path: `[${index}].${issue.path}`,
|
|
167
|
+
})),
|
|
168
|
+
];
|
|
169
|
+
});
|
|
170
|
+
if (issues.length > 0)
|
|
171
|
+
throw new CustomObjectRecordValidationError(
|
|
172
|
+
definition,
|
|
173
|
+
operation === 'create' ? 'bulk-create' : 'bulk-update',
|
|
174
|
+
issues,
|
|
175
|
+
);
|
|
176
|
+
return rows.map((row) =>
|
|
177
|
+
operation === 'create' ?
|
|
178
|
+
serializeInput(definition, row)
|
|
179
|
+
: { id: row['id'], ...serializeInput(definition, row) },
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
const query = async (ctx: ObjectRecordsContext, options: Parameters<ObjectRecords<D>['query']>[1]) => {
|
|
183
|
+
const page = await adapter(ctx).query(definition.apiName, options ?? {});
|
|
184
|
+
return { cursor: page.cursor, results: page.results.map(decode) };
|
|
185
|
+
};
|
|
186
|
+
return Object.freeze<ObjectRecords<D>>({
|
|
187
|
+
async create(ctx, input) {
|
|
188
|
+
assertObjectInput(definition, input, 'create');
|
|
189
|
+
return decode(await adapter(ctx).create(definition.apiName, serializeInput(definition, input)));
|
|
190
|
+
},
|
|
191
|
+
async createMany(ctx, rows, options) {
|
|
192
|
+
const rowsToWrite = serializeBatch(rows, 'create');
|
|
193
|
+
return (await adapter(ctx).bulkCreate(definition.apiName, { ...options, rowsToWrite })).map(decode);
|
|
194
|
+
},
|
|
195
|
+
async get(ctx, recordID) {
|
|
196
|
+
return decode(await adapter(ctx).retrieve(definition.apiName, recordID));
|
|
197
|
+
},
|
|
198
|
+
async getByExternalID(ctx, externalID) {
|
|
199
|
+
return decode(await adapter(ctx).retrieveByExternalID(definition.apiName, externalID));
|
|
200
|
+
},
|
|
201
|
+
async update(ctx, recordID, patch) {
|
|
202
|
+
assertObjectInput(definition, patch, 'update');
|
|
203
|
+
return decode(
|
|
204
|
+
await adapter(ctx).update(definition.apiName, recordID, serializeInput(definition, patch)),
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
async updateMany(ctx, rows, options) {
|
|
208
|
+
const rowsToUpdate = serializeBatch(rows, 'update');
|
|
209
|
+
return (await adapter(ctx).bulkUpdate(definition.apiName, { ...options, rowsToUpdate })).map(decode);
|
|
210
|
+
},
|
|
211
|
+
delete: (ctx, recordID) => adapter(ctx).delete(definition.apiName, recordID),
|
|
212
|
+
deleteMany: (ctx, recordIDs, options) =>
|
|
213
|
+
adapter(ctx).bulkDelete(definition.apiName, { ...options, rowsToDelete: recordIDs }),
|
|
214
|
+
list: (ctx, { where, ...options } = {}) =>
|
|
215
|
+
query(ctx, { ...options, ...(where === undefined ? {} : { query: where.text }) }),
|
|
216
|
+
query,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineComponent, withApiName, validateCustomApiName, type ComponentDefinition } from './component';
|
|
2
|
+
import { CustomObjectAction, type CustomObjectActionProps } from '../custom-object-action';
|
|
3
|
+
import { manifestObject, type ObjectReference } from './custom-object';
|
|
4
|
+
|
|
5
|
+
export type DefineActionProps = Omit<CustomObjectActionProps, 'actionId' | 'apiName'> & {
|
|
6
|
+
apiName: `${string}__c`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function defineAction(object: ObjectReference, props: DefineActionProps): CustomObjectAction {
|
|
10
|
+
validateCustomApiName(props.apiName);
|
|
11
|
+
const action = withApiName(
|
|
12
|
+
new CustomObjectAction(manifestObject(object), { ...props, actionId: props.apiName }),
|
|
13
|
+
props.apiName,
|
|
14
|
+
);
|
|
15
|
+
currentFunction.set(action, props.function);
|
|
16
|
+
const setFunction = action.setFunction.bind(action);
|
|
17
|
+
action.setFunction = (definition) => {
|
|
18
|
+
setFunction(definition);
|
|
19
|
+
currentFunction.set(action, definition);
|
|
20
|
+
return action;
|
|
21
|
+
};
|
|
22
|
+
return actionComponent.register(action, object, props);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const currentFunction = new WeakMap<CustomObjectAction, CustomObjectActionProps['function']>();
|
|
26
|
+
|
|
27
|
+
const actionComponent: ComponentDefinition<typeof defineAction> = defineComponent({
|
|
28
|
+
type: 'CUSTOM_OBJECT_ACTION',
|
|
29
|
+
define: defineAction,
|
|
30
|
+
references: (definition, object) => () => [object, currentFunction.get(definition)!],
|
|
31
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ACPAgent, type ACPAgentProps, type ACPAgentSourceFile } from '../acp-agent';
|
|
2
|
+
import { detachedManifestScope, defineComponent, sourceEntry, validateCustomApiName } from './component';
|
|
3
|
+
import type { RipplingSDK } from '../../../client';
|
|
4
|
+
import type { RequestOptions } from '../../../internal/request-options';
|
|
5
|
+
import type {
|
|
6
|
+
SessionCreateParams,
|
|
7
|
+
SessionListParams,
|
|
8
|
+
SessionCreateResponse,
|
|
9
|
+
SessionListResponse,
|
|
10
|
+
SessionListResponsesPageCursorURL,
|
|
11
|
+
} from '../../../resources/agents/sessions/sessions';
|
|
12
|
+
import type { AgentRetrieveResponse } from '../../../resources/agents/agents';
|
|
13
|
+
import type { APIPromise } from '../../../core/api-promise';
|
|
14
|
+
import type { PagePromise } from '../../../core/pagination';
|
|
15
|
+
|
|
16
|
+
export type DefinedAgentProps = { apiName: `${string}__c` } & (
|
|
17
|
+
| (ACPAgentProps & { source?: never })
|
|
18
|
+
| (Omit<ACPAgentProps, 'files' | 'entrypoint'> & { source: URL; files?: never; entrypoint?: never })
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** Authenticated agent resources supplied per call. */
|
|
22
|
+
export interface AgentOperationsContext {
|
|
23
|
+
readonly agents: {
|
|
24
|
+
readonly retrieve: RipplingSDK['agents']['retrieve'];
|
|
25
|
+
readonly sessions: Pick<RipplingSDK['agents']['sessions'], 'create' | 'list'>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AgentSessions {
|
|
30
|
+
create(
|
|
31
|
+
ctx: AgentOperationsContext,
|
|
32
|
+
params: Omit<SessionCreateParams, 'agent_id'>,
|
|
33
|
+
options?: RequestOptions,
|
|
34
|
+
): APIPromise<SessionCreateResponse>;
|
|
35
|
+
list(
|
|
36
|
+
ctx: AgentOperationsContext,
|
|
37
|
+
params?: SessionListParams,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): PagePromise<SessionListResponsesPageCursorURL, SessionListResponse>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AgentOperations {
|
|
43
|
+
retrieve(ctx: AgentOperationsContext, options?: RequestOptions): APIPromise<AgentRetrieveResponse>;
|
|
44
|
+
sessions: AgentSessions;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AgentClient {
|
|
48
|
+
retrieve(options?: RequestOptions): APIPromise<AgentRetrieveResponse>;
|
|
49
|
+
sessions: {
|
|
50
|
+
create(
|
|
51
|
+
params: Omit<SessionCreateParams, 'agent_id'>,
|
|
52
|
+
options?: RequestOptions,
|
|
53
|
+
): APIPromise<SessionCreateResponse>;
|
|
54
|
+
list(
|
|
55
|
+
params?: SessionListParams,
|
|
56
|
+
options?: RequestOptions,
|
|
57
|
+
): PagePromise<SessionListResponsesPageCursorURL, SessionListResponse>;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function defineAgent(props: DefinedAgentProps): DefinedAgent {
|
|
62
|
+
if (props.source !== undefined && (props.files !== undefined || props.entrypoint !== undefined))
|
|
63
|
+
throw new Error('Define an agent with either source or files/entrypoint, not both.');
|
|
64
|
+
return agentComponent.register(new DefinedAgent(props), props);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class DefinedAgent extends ACPAgent {
|
|
68
|
+
private _source: URL | undefined;
|
|
69
|
+
readonly retrieve: (
|
|
70
|
+
ctx: AgentOperationsContext,
|
|
71
|
+
options?: RequestOptions,
|
|
72
|
+
) => APIPromise<AgentRetrieveResponse>;
|
|
73
|
+
readonly sessions: AgentSessions;
|
|
74
|
+
constructor(props: DefinedAgentProps) {
|
|
75
|
+
validateCustomApiName(props.apiName);
|
|
76
|
+
if (props.source !== undefined && props.source.protocol !== 'file:')
|
|
77
|
+
throw new Error('Component source must be a file URL.');
|
|
78
|
+
super(
|
|
79
|
+
detachedManifestScope,
|
|
80
|
+
props.source !== undefined ? { ...props, files: [], entrypoint: 'index.ts' } : (props as ACPAgentProps),
|
|
81
|
+
);
|
|
82
|
+
this._source = props.source === undefined ? undefined : new URL(props.source.href);
|
|
83
|
+
const operations = createAgentOperations(this);
|
|
84
|
+
this.retrieve = operations.retrieve;
|
|
85
|
+
this.sessions = operations.sessions;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get source(): URL | undefined {
|
|
89
|
+
return this._source;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Replaces inline files or a file-backed source with the supplied files and entrypoint. */
|
|
93
|
+
override setSource(files: ACPAgentSourceFile[], entrypoint: string): this {
|
|
94
|
+
super.setSource(files, entrypoint);
|
|
95
|
+
this._source = undefined;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface AgentMetadata {
|
|
101
|
+
type: 'ACP_AGENT';
|
|
102
|
+
api_name: string;
|
|
103
|
+
source_agent_id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
entrypoint: string;
|
|
106
|
+
files: { type: 'ACP_AGENT'; path: string; content: string; kind: string }[];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @internal Shared with the legacy client helper, including constructor-based agent references. */
|
|
110
|
+
function createAgentOperations(definition: ACPAgent): AgentOperations {
|
|
111
|
+
return {
|
|
112
|
+
retrieve: (ctx: AgentOperationsContext, options?: RequestOptions) =>
|
|
113
|
+
ctx.agents.retrieve(definition.getApiName(), options),
|
|
114
|
+
sessions: {
|
|
115
|
+
create: (
|
|
116
|
+
ctx: AgentOperationsContext,
|
|
117
|
+
params: Omit<SessionCreateParams, 'agent_id'>,
|
|
118
|
+
options?: RequestOptions,
|
|
119
|
+
) => ctx.agents.sessions.create({ ...params, agent_id: definition.getApiName() }, options),
|
|
120
|
+
list: (ctx: AgentOperationsContext, params?: SessionListParams, options?: RequestOptions) =>
|
|
121
|
+
ctx.agents.sessions.list(definition.getApiName(), params, options),
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const agentComponent = defineComponent({
|
|
127
|
+
type: 'ACP_AGENT',
|
|
128
|
+
define: defineAgent,
|
|
129
|
+
serialize: (definition) =>
|
|
130
|
+
sourceEntry(definition.toDict() as AgentMetadata, definition.source, (config, content) => ({
|
|
131
|
+
...config,
|
|
132
|
+
files: [{ type: 'ACP_AGENT' as const, path: 'index.ts', content, kind: 'typescript' }],
|
|
133
|
+
entrypoint: 'index.ts',
|
|
134
|
+
})),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/** @internal Forward client helpers to the definition operations. */
|
|
138
|
+
export function createAgentClient(ctx: AgentOperationsContext, definition: ACPAgent): AgentClient {
|
|
139
|
+
const operations = createAgentOperations(definition);
|
|
140
|
+
return {
|
|
141
|
+
retrieve: (options?: RequestOptions) => operations.retrieve(ctx, options),
|
|
142
|
+
sessions: {
|
|
143
|
+
create: (params: Omit<SessionCreateParams, 'agent_id'>, options?: RequestOptions) =>
|
|
144
|
+
operations.sessions.create(ctx, params, options),
|
|
145
|
+
list: (params?: SessionListParams, options?: RequestOptions) =>
|
|
146
|
+
operations.sessions.list(ctx, params, options),
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineComponent, detachedManifestScope, type ComponentDefinition } from './component';
|
|
2
|
+
import { App, type AppProps } from '../app';
|
|
3
|
+
|
|
4
|
+
export function defineApp(props: AppProps): App {
|
|
5
|
+
return appComponent.register(new App(detachedManifestScope, props), props);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const appComponent: ComponentDefinition<typeof defineApp> = defineComponent({
|
|
9
|
+
type: 'CUSTOM_APP',
|
|
10
|
+
define: defineApp,
|
|
11
|
+
references: (_definition, props) => props.pages,
|
|
12
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CustomObjectCategoryDefinition } from '../../../core/platform/custom-objects/category';
|
|
2
|
+
import { Category, type CategoryProps } from '../category';
|
|
3
|
+
import { detachedManifestScope, defineComponent, validateCustomApiName } from './component';
|
|
4
|
+
|
|
5
|
+
export type DefineCustomObjectCategoryProps<TApiName extends `${string}__c` = `${string}__c`> =
|
|
6
|
+
CategoryProps & { apiName: TApiName };
|
|
7
|
+
|
|
8
|
+
export function defineCategory<const TApiName extends `${string}__c`>(
|
|
9
|
+
props: DefineCustomObjectCategoryProps<TApiName>,
|
|
10
|
+
): Category & CustomObjectCategoryDefinition<TApiName extends `${infer N}__c` ? N : never>;
|
|
11
|
+
export function defineCategory(props: CategoryProps): Category | CustomObjectCategoryDefinition {
|
|
12
|
+
validateCustomApiName(props.apiName);
|
|
13
|
+
return categoryComponent.register(
|
|
14
|
+
Object.assign(new Category(detachedManifestScope, props), {
|
|
15
|
+
apiName: props.apiName,
|
|
16
|
+
name: props.apiName.replace(/__c$/, ''),
|
|
17
|
+
displayName: props.name,
|
|
18
|
+
description: props.description,
|
|
19
|
+
}),
|
|
20
|
+
props,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const defineCustomObjectCategory = defineCategory;
|
|
25
|
+
|
|
26
|
+
export const categoryComponent = defineComponent({
|
|
27
|
+
type: 'CUSTOM_CATEGORY',
|
|
28
|
+
define: defineCategory,
|
|
29
|
+
serialize: (definition) => ({
|
|
30
|
+
type: 'CUSTOM_CATEGORY',
|
|
31
|
+
api_name: definition.apiName,
|
|
32
|
+
name: definition.displayName,
|
|
33
|
+
description: definition.description ?? '',
|
|
34
|
+
}),
|
|
35
|
+
});
|