@rippling/rippling-sdk 0.2.0-alpha.83 → 0.2.0-alpha.85
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/examples/manifest/custom-object-creation-workflow/custom-object-creation-workflow.ts +44 -26
- package/examples/manifest/dental-practice-management/dental-practice-management.ts +470 -142
- package/examples/manifest/dental-practice-management/functions/chair-schedule.ts +23 -13
- package/examples/manifest/dental-practice-management/functions/complete-visit.ts +55 -32
- package/examples/manifest/dental-practice-management/functions/operatory-list.ts +23 -13
- package/examples/manifest/dental-practice-management/functions/patient-list.ts +23 -13
- package/examples/manifest/dental-practice-management/functions/treatment-plan-list.ts +23 -13
- package/examples/manifest/existing-manifest-mutations/existing-manifest-mutations.ts +23 -68
- package/examples/manifest/field-service-dispatch/field-service-dispatch.ts +375 -102
- package/examples/manifest/grant-program-management/grant-program-management.ts +419 -125
- package/examples/manifest/gym-membership-management/functions/check-in-desk.ts +23 -13
- package/examples/manifest/gym-membership-management/functions/member-list.ts +23 -13
- package/examples/manifest/gym-membership-management/functions/today-schedule.ts +23 -13
- package/examples/manifest/gym-membership-management/functions/trainer-list.ts +23 -13
- package/examples/manifest/gym-membership-management/gym-membership-management.ts +442 -92
- package/examples/manifest/procurement-approval-hub/procurement-approval-hub.ts +408 -122
- package/examples/manifest/simple-todo-app/functions/mark-done.ts +12 -16
- package/examples/manifest/simple-todo-app/functions/todo-list.ts +23 -13
- package/examples/manifest/simple-todo-app/simple-todo-app.ts +109 -40
- package/examples/manifest/todo-app-without-object-list-view/functions/todo-page.ts +193 -166
- package/examples/manifest/todo-app-without-object-list-view/todo-app-without-object-list-view.ts +47 -24
- package/package.json +13 -7
- package/resources/custom-objects/custom-objects.d.mts +0 -7
- package/resources/custom-objects/custom-objects.d.mts.map +1 -1
- package/resources/custom-objects/custom-objects.d.ts +0 -7
- package/resources/custom-objects/custom-objects.d.ts.map +1 -1
- package/resources/custom-objects/custom-objects.js.map +1 -1
- package/resources/custom-objects/custom-objects.mjs.map +1 -1
- package/resources/custom-objects/fields.d.mts +14 -128
- package/resources/custom-objects/fields.d.mts.map +1 -1
- package/resources/custom-objects/fields.d.ts +14 -128
- package/resources/custom-objects/fields.d.ts.map +1 -1
- package/src/resources/custom-objects/custom-objects.ts +0 -8
- package/src/resources/custom-objects/fields.ts +13 -191
- package/src/tsconfig.json +1 -1
- 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/core/platform/custom-objects/category.d.mts +0 -125
- package/core/platform/custom-objects/category.d.mts.map +0 -1
- package/core/platform/custom-objects/category.d.ts +0 -125
- package/core/platform/custom-objects/category.d.ts.map +0 -1
- package/core/platform/custom-objects/category.js +0 -188
- package/core/platform/custom-objects/category.js.map +0 -1
- package/core/platform/custom-objects/category.mjs +0 -178
- package/core/platform/custom-objects/category.mjs.map +0 -1
- package/core/platform/custom-objects/definition.d.mts +0 -147
- package/core/platform/custom-objects/definition.d.mts.map +0 -1
- package/core/platform/custom-objects/definition.d.ts +0 -147
- package/core/platform/custom-objects/definition.d.ts.map +0 -1
- package/core/platform/custom-objects/definition.js +0 -200
- package/core/platform/custom-objects/definition.js.map +0 -1
- package/core/platform/custom-objects/definition.mjs +0 -190
- package/core/platform/custom-objects/definition.mjs.map +0 -1
- package/core/platform/custom-objects/fields.d.mts +0 -302
- package/core/platform/custom-objects/fields.d.mts.map +0 -1
- package/core/platform/custom-objects/fields.d.ts +0 -302
- package/core/platform/custom-objects/fields.d.ts.map +0 -1
- package/core/platform/custom-objects/fields.js +0 -369
- package/core/platform/custom-objects/fields.js.map +0 -1
- package/core/platform/custom-objects/fields.mjs +0 -347
- package/core/platform/custom-objects/fields.mjs.map +0 -1
- package/core/platform/custom-objects/function-runtime.d.mts +0 -42
- package/core/platform/custom-objects/function-runtime.d.mts.map +0 -1
- package/core/platform/custom-objects/function-runtime.d.ts +0 -42
- package/core/platform/custom-objects/function-runtime.d.ts.map +0 -1
- package/core/platform/custom-objects/function-runtime.js +0 -38
- package/core/platform/custom-objects/function-runtime.js.map +0 -1
- package/core/platform/custom-objects/function-runtime.mjs +0 -35
- package/core/platform/custom-objects/function-runtime.mjs.map +0 -1
- package/core/platform/custom-objects/lifecycle.d.mts +0 -83
- package/core/platform/custom-objects/lifecycle.d.mts.map +0 -1
- package/core/platform/custom-objects/lifecycle.d.ts +0 -83
- package/core/platform/custom-objects/lifecycle.d.ts.map +0 -1
- package/core/platform/custom-objects/lifecycle.js +0 -372
- package/core/platform/custom-objects/lifecycle.js.map +0 -1
- package/core/platform/custom-objects/lifecycle.mjs +0 -367
- package/core/platform/custom-objects/lifecycle.mjs.map +0 -1
- package/core/platform/custom-objects/manager.d.mts +0 -354
- package/core/platform/custom-objects/manager.d.mts.map +0 -1
- package/core/platform/custom-objects/manager.d.ts +0 -354
- package/core/platform/custom-objects/manager.d.ts.map +0 -1
- package/core/platform/custom-objects/manager.js +0 -646
- package/core/platform/custom-objects/manager.js.map +0 -1
- package/core/platform/custom-objects/manager.mjs +0 -637
- package/core/platform/custom-objects/manager.mjs.map +0 -1
- package/core/platform/custom-objects/provisioning.d.mts +0 -138
- package/core/platform/custom-objects/provisioning.d.mts.map +0 -1
- package/core/platform/custom-objects/provisioning.d.ts +0 -138
- package/core/platform/custom-objects/provisioning.d.ts.map +0 -1
- package/core/platform/custom-objects/provisioning.js +0 -455
- package/core/platform/custom-objects/provisioning.js.map +0 -1
- package/core/platform/custom-objects/provisioning.mjs +0 -447
- package/core/platform/custom-objects/provisioning.mjs.map +0 -1
- package/core/platform/custom-objects/rql.d.mts +0 -122
- package/core/platform/custom-objects/rql.d.mts.map +0 -1
- package/core/platform/custom-objects/rql.d.ts +0 -122
- package/core/platform/custom-objects/rql.d.ts.map +0 -1
- package/core/platform/custom-objects/rql.js +0 -225
- package/core/platform/custom-objects/rql.js.map +0 -1
- package/core/platform/custom-objects/rql.mjs +0 -222
- package/core/platform/custom-objects/rql.mjs.map +0 -1
- package/core/platform/custom-objects/schema-manager.d.mts +0 -203
- package/core/platform/custom-objects/schema-manager.d.mts.map +0 -1
- package/core/platform/custom-objects/schema-manager.d.ts +0 -203
- package/core/platform/custom-objects/schema-manager.d.ts.map +0 -1
- package/core/platform/custom-objects/schema-manager.js +0 -256
- package/core/platform/custom-objects/schema-manager.js.map +0 -1
- package/core/platform/custom-objects/schema-manager.mjs +0 -249
- package/core/platform/custom-objects/schema-manager.mjs.map +0 -1
- package/core/platform/custom-objects/typed-rql.d.mts +0 -157
- package/core/platform/custom-objects/typed-rql.d.mts.map +0 -1
- package/core/platform/custom-objects/typed-rql.d.ts +0 -157
- package/core/platform/custom-objects/typed-rql.d.ts.map +0 -1
- package/core/platform/custom-objects/typed-rql.js +0 -583
- package/core/platform/custom-objects/typed-rql.js.map +0 -1
- package/core/platform/custom-objects/typed-rql.mjs +0 -580
- package/core/platform/custom-objects/typed-rql.mjs.map +0 -1
- package/core/platform/custom-objects/types.d.mts +0 -549
- package/core/platform/custom-objects/types.d.mts.map +0 -1
- package/core/platform/custom-objects/types.d.ts +0 -549
- package/core/platform/custom-objects/types.d.ts.map +0 -1
- package/core/platform/custom-objects/types.js +0 -20
- package/core/platform/custom-objects/types.js.map +0 -1
- package/core/platform/custom-objects/types.mjs +0 -17
- package/core/platform/custom-objects/types.mjs.map +0 -1
- package/core/platform/custom-objects/validation.d.mts +0 -97
- package/core/platform/custom-objects/validation.d.mts.map +0 -1
- package/core/platform/custom-objects/validation.d.ts +0 -97
- package/core/platform/custom-objects/validation.d.ts.map +0 -1
- package/core/platform/custom-objects/validation.js +0 -477
- package/core/platform/custom-objects/validation.js.map +0 -1
- package/core/platform/custom-objects/validation.mjs +0 -465
- package/core/platform/custom-objects/validation.mjs.map +0 -1
- package/core/platform/custom-objects.d.mts +0 -67
- package/core/platform/custom-objects.d.mts.map +0 -1
- package/core/platform/custom-objects.d.ts +0 -67
- package/core/platform/custom-objects.d.ts.map +0 -1
- package/core/platform/custom-objects.js +0 -118
- package/core/platform/custom-objects.js.map +0 -1
- package/core/platform/custom-objects.mjs +0 -45
- package/core/platform/custom-objects.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/action.d.mts +0 -58
- package/core/platform/manifest/custom-objects/action.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/action.d.ts +0 -58
- package/core/platform/manifest/custom-objects/action.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/action.js +0 -44
- package/core/platform/manifest/custom-objects/action.js.map +0 -1
- package/core/platform/manifest/custom-objects/action.mjs +0 -40
- package/core/platform/manifest/custom-objects/action.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/conditions.d.mts +0 -240
- package/core/platform/manifest/custom-objects/conditions.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/conditions.d.ts +0 -240
- package/core/platform/manifest/custom-objects/conditions.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/conditions.js +0 -326
- package/core/platform/manifest/custom-objects/conditions.js.map +0 -1
- package/core/platform/manifest/custom-objects/conditions.mjs +0 -321
- package/core/platform/manifest/custom-objects/conditions.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/existing.d.mts +0 -87
- package/core/platform/manifest/custom-objects/existing.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/existing.d.ts +0 -87
- package/core/platform/manifest/custom-objects/existing.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/existing.js +0 -113
- package/core/platform/manifest/custom-objects/existing.js.map +0 -1
- package/core/platform/manifest/custom-objects/existing.mjs +0 -109
- package/core/platform/manifest/custom-objects/existing.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/field-resolution.d.mts +0 -48
- package/core/platform/manifest/custom-objects/field-resolution.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/field-resolution.d.ts +0 -48
- package/core/platform/manifest/custom-objects/field-resolution.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/field-resolution.js +0 -61
- package/core/platform/manifest/custom-objects/field-resolution.js.map +0 -1
- package/core/platform/manifest/custom-objects/field-resolution.mjs +0 -58
- package/core/platform/manifest/custom-objects/field-resolution.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/function-file.d.mts +0 -87
- package/core/platform/manifest/custom-objects/function-file.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/function-file.d.ts +0 -87
- package/core/platform/manifest/custom-objects/function-file.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/function-file.js +0 -76
- package/core/platform/manifest/custom-objects/function-file.js.map +0 -1
- package/core/platform/manifest/custom-objects/function-file.mjs +0 -69
- package/core/platform/manifest/custom-objects/function-file.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/list-view.d.mts +0 -65
- package/core/platform/manifest/custom-objects/list-view.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/list-view.d.ts +0 -65
- package/core/platform/manifest/custom-objects/list-view.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/list-view.js +0 -33
- package/core/platform/manifest/custom-objects/list-view.js.map +0 -1
- package/core/platform/manifest/custom-objects/list-view.mjs +0 -30
- package/core/platform/manifest/custom-objects/list-view.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/object-list-page.d.mts +0 -43
- package/core/platform/manifest/custom-objects/object-list-page.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/object-list-page.d.ts +0 -43
- package/core/platform/manifest/custom-objects/object-list-page.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/object-list-page.js +0 -54
- package/core/platform/manifest/custom-objects/object-list-page.js.map +0 -1
- package/core/platform/manifest/custom-objects/object-list-page.mjs +0 -50
- package/core/platform/manifest/custom-objects/object-list-page.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/page-layout.d.mts +0 -142
- package/core/platform/manifest/custom-objects/page-layout.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/page-layout.d.ts +0 -142
- package/core/platform/manifest/custom-objects/page-layout.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/page-layout.js +0 -184
- package/core/platform/manifest/custom-objects/page-layout.js.map +0 -1
- package/core/platform/manifest/custom-objects/page-layout.mjs +0 -180
- package/core/platform/manifest/custom-objects/page-layout.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/register.d.mts +0 -87
- package/core/platform/manifest/custom-objects/register.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/register.d.ts +0 -87
- package/core/platform/manifest/custom-objects/register.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/register.js +0 -395
- package/core/platform/manifest/custom-objects/register.js.map +0 -1
- package/core/platform/manifest/custom-objects/register.mjs +0 -391
- package/core/platform/manifest/custom-objects/register.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/rule.d.mts +0 -113
- package/core/platform/manifest/custom-objects/rule.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/rule.d.ts +0 -113
- package/core/platform/manifest/custom-objects/rule.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/rule.js +0 -49
- package/core/platform/manifest/custom-objects/rule.js.map +0 -1
- package/core/platform/manifest/custom-objects/rule.mjs +0 -45
- package/core/platform/manifest/custom-objects/rule.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/sdui-page.d.mts +0 -214
- package/core/platform/manifest/custom-objects/sdui-page.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/sdui-page.d.ts +0 -214
- package/core/platform/manifest/custom-objects/sdui-page.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/sdui-page.js +0 -194
- package/core/platform/manifest/custom-objects/sdui-page.js.map +0 -1
- package/core/platform/manifest/custom-objects/sdui-page.mjs +0 -182
- package/core/platform/manifest/custom-objects/sdui-page.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/typed-condition.d.mts +0 -28
- package/core/platform/manifest/custom-objects/typed-condition.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/typed-condition.d.ts +0 -28
- package/core/platform/manifest/custom-objects/typed-condition.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/typed-condition.js +0 -434
- package/core/platform/manifest/custom-objects/typed-condition.js.map +0 -1
- package/core/platform/manifest/custom-objects/typed-condition.mjs +0 -431
- package/core/platform/manifest/custom-objects/typed-condition.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/types.d.mts +0 -29
- package/core/platform/manifest/custom-objects/types.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/types.d.ts +0 -29
- package/core/platform/manifest/custom-objects/types.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/types.js +0 -3
- package/core/platform/manifest/custom-objects/types.js.map +0 -1
- package/core/platform/manifest/custom-objects/types.mjs +0 -2
- package/core/platform/manifest/custom-objects/types.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/validation.d.mts +0 -44
- package/core/platform/manifest/custom-objects/validation.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/validation.d.ts +0 -44
- package/core/platform/manifest/custom-objects/validation.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/validation.js +0 -30
- package/core/platform/manifest/custom-objects/validation.js.map +0 -1
- package/core/platform/manifest/custom-objects/validation.mjs +0 -27
- package/core/platform/manifest/custom-objects/validation.mjs.map +0 -1
- package/core/platform/manifest/custom-objects/workflow.d.mts +0 -47
- package/core/platform/manifest/custom-objects/workflow.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects/workflow.d.ts +0 -47
- package/core/platform/manifest/custom-objects/workflow.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects/workflow.js +0 -38
- package/core/platform/manifest/custom-objects/workflow.js.map +0 -1
- package/core/platform/manifest/custom-objects/workflow.mjs +0 -34
- package/core/platform/manifest/custom-objects/workflow.mjs.map +0 -1
- package/core/platform/manifest/custom-objects.d.mts +0 -85
- package/core/platform/manifest/custom-objects.d.mts.map +0 -1
- package/core/platform/manifest/custom-objects.d.ts +0 -85
- package/core/platform/manifest/custom-objects.d.ts.map +0 -1
- package/core/platform/manifest/custom-objects.js +0 -84
- package/core/platform/manifest/custom-objects.js.map +0 -1
- package/core/platform/manifest/custom-objects.mjs +0 -55
- package/core/platform/manifest/custom-objects.mjs.map +0 -1
- package/examples/manifest/custom-object-creation-workflow/functions/intake-request-created.ts +0 -20
- package/examples/manifest/custom-object-creation-workflow/schema.ts +0 -29
- package/examples/manifest/dental-practice-management/schema.ts +0 -298
- package/examples/manifest/field-service-dispatch/schema.ts +0 -248
- package/examples/manifest/grant-program-management/schema.ts +0 -269
- package/examples/manifest/gym-membership-management/schema.ts +0 -266
- package/examples/manifest/procurement-approval-hub/functions/route-purchase-request.ts +0 -20
- package/examples/manifest/procurement-approval-hub/schema.ts +0 -256
- package/examples/manifest/simple-todo-app/schema.ts +0 -60
- package/examples/manifest/todo-app-without-object-list-view/schema.ts +0 -28
- package/src/core/platform/README.md +0 -20
- package/src/core/platform/custom-objects/category.ts +0 -294
- package/src/core/platform/custom-objects/definition.ts +0 -373
- package/src/core/platform/custom-objects/fields.ts +0 -653
- package/src/core/platform/custom-objects/function-runtime.ts +0 -76
- package/src/core/platform/custom-objects/lifecycle.ts +0 -557
- package/src/core/platform/custom-objects/manager.ts +0 -959
- package/src/core/platform/custom-objects/provisioning.ts +0 -672
- package/src/core/platform/custom-objects/rql.ts +0 -375
- package/src/core/platform/custom-objects/schema-manager.ts +0 -351
- package/src/core/platform/custom-objects/typed-rql.ts +0 -1273
- package/src/core/platform/custom-objects/types.ts +0 -753
- package/src/core/platform/custom-objects/validation.ts +0 -573
- package/src/core/platform/custom-objects.ts +0 -269
- package/src/core/platform/manifest/README.md +0 -26
- package/src/core/platform/manifest/custom-objects/action.ts +0 -87
- package/src/core/platform/manifest/custom-objects/conditions.ts +0 -762
- package/src/core/platform/manifest/custom-objects/existing.ts +0 -221
- package/src/core/platform/manifest/custom-objects/field-resolution.ts +0 -116
- package/src/core/platform/manifest/custom-objects/function-file.ts +0 -149
- package/src/core/platform/manifest/custom-objects/list-view.ts +0 -95
- package/src/core/platform/manifest/custom-objects/object-list-page.ts +0 -87
- package/src/core/platform/manifest/custom-objects/page-layout.ts +0 -380
- package/src/core/platform/manifest/custom-objects/register.ts +0 -555
- package/src/core/platform/manifest/custom-objects/rule.ts +0 -192
- package/src/core/platform/manifest/custom-objects/sdui-page.ts +0 -515
- package/src/core/platform/manifest/custom-objects/typed-condition.ts +0 -617
- package/src/core/platform/manifest/custom-objects/types.ts +0 -92
- package/src/core/platform/manifest/custom-objects/validation.ts +0 -70
- package/src/core/platform/manifest/custom-objects/workflow.ts +0 -71
- package/src/core/platform/manifest/custom-objects.ts +0 -203
- package/src/pebble-sdui-web-custom-apps-shim.d.ts +0 -3
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
import type { AnyCustomObjectDefinition, FieldNames } from '../../custom-objects/types';
|
|
2
|
-
import type {
|
|
3
|
-
ManifestConditionCategory,
|
|
4
|
-
ManifestConditionFragment,
|
|
5
|
-
ManifestCustomObjectTarget,
|
|
6
|
-
} from './conditions';
|
|
7
|
-
import type { ManifestRegistration } from './types';
|
|
8
|
-
|
|
9
|
-
const STANDARD_TYPED_CONDITION_FIELDS = [
|
|
10
|
-
'id',
|
|
11
|
-
'name',
|
|
12
|
-
'created_at',
|
|
13
|
-
'updated_at',
|
|
14
|
-
'system_updated_at',
|
|
15
|
-
'external_id',
|
|
16
|
-
'owner_role',
|
|
17
|
-
'created_by',
|
|
18
|
-
'last_modified_by',
|
|
19
|
-
] as const;
|
|
20
|
-
|
|
21
|
-
const STANDARD_TYPED_CONDITION_LOOKUP_FIELDS = new Set(['owner_role', 'created_by', 'last_modified_by']);
|
|
22
|
-
|
|
23
|
-
/** Standard field-name strings accepted by {@link typedCondition}. */
|
|
24
|
-
export type ParsedConditionStandardFieldName<TDefinition extends AnyCustomObjectDefinition> =
|
|
25
|
-
(typeof STANDARD_TYPED_CONDITION_FIELDS)[number];
|
|
26
|
-
|
|
27
|
-
/** Field-name strings accepted by {@link typedCondition}. */
|
|
28
|
-
export type ParsedConditionFieldName<TDefinition extends AnyCustomObjectDefinition> =
|
|
29
|
-
| ParsedConditionStandardFieldName<TDefinition>
|
|
30
|
-
| FieldNames<TDefinition>;
|
|
31
|
-
|
|
32
|
-
interface ParsedConditionStringLiteral {
|
|
33
|
-
readonly kind: 'string';
|
|
34
|
-
readonly value: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface ParsedConditionNumberLiteral {
|
|
38
|
-
readonly kind: 'number';
|
|
39
|
-
readonly value: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface ParsedConditionBooleanLiteral {
|
|
43
|
-
readonly kind: 'boolean';
|
|
44
|
-
readonly value: boolean;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface ParsedConditionNullLiteral {
|
|
48
|
-
readonly kind: 'null';
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface ParsedConditionFunctionLiteral {
|
|
52
|
-
readonly kind: 'function';
|
|
53
|
-
readonly name: 'TODAY';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface ParsedConditionArrayLiteral {
|
|
57
|
-
readonly kind: 'array';
|
|
58
|
-
readonly value: readonly ParsedConditionScalarLiteral[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
type ParsedConditionScalarLiteral =
|
|
62
|
-
| ParsedConditionStringLiteral
|
|
63
|
-
| ParsedConditionNumberLiteral
|
|
64
|
-
| ParsedConditionBooleanLiteral
|
|
65
|
-
| ParsedConditionNullLiteral;
|
|
66
|
-
|
|
67
|
-
type ParsedConditionLiteral =
|
|
68
|
-
| ParsedConditionScalarLiteral
|
|
69
|
-
| ParsedConditionFunctionLiteral
|
|
70
|
-
| ParsedConditionArrayLiteral;
|
|
71
|
-
|
|
72
|
-
interface ParsedConditionComparisonNode {
|
|
73
|
-
readonly kind: 'comparison';
|
|
74
|
-
readonly field: string;
|
|
75
|
-
readonly operator: '==' | '!=' | '<' | '<=' | '>' | '>=' | 'IN' | 'NOT_IN';
|
|
76
|
-
readonly value: ParsedConditionLiteral;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
interface ParsedConditionLogicalNode {
|
|
80
|
-
readonly kind: 'logical';
|
|
81
|
-
readonly operator: 'AND' | 'OR';
|
|
82
|
-
readonly operands: readonly ParsedConditionExpressionNode[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
interface ParsedConditionNotNode {
|
|
86
|
-
readonly kind: 'not';
|
|
87
|
-
readonly operand: ParsedConditionExpressionNode;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
type ParsedConditionExpressionNode =
|
|
91
|
-
| ParsedConditionComparisonNode
|
|
92
|
-
| ParsedConditionLogicalNode
|
|
93
|
-
| ParsedConditionNotNode;
|
|
94
|
-
|
|
95
|
-
interface RuntimeParsedConditionState {
|
|
96
|
-
text: string;
|
|
97
|
-
index: number;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface RuntimeConditionFieldMetadata {
|
|
101
|
-
readonly apiName: string;
|
|
102
|
-
readonly category: ManifestConditionCategory;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function isManifestRegistration<TDefinition extends AnyCustomObjectDefinition>(
|
|
106
|
-
target: ManifestCustomObjectTarget<TDefinition>,
|
|
107
|
-
): target is ManifestRegistration<TDefinition> {
|
|
108
|
-
return typeof target === 'object' && target != null && 'definition' in target && 'object' in target;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function resolveTargetDefinition<TDefinition extends AnyCustomObjectDefinition>(
|
|
112
|
-
target: ManifestCustomObjectTarget<TDefinition>,
|
|
113
|
-
): TDefinition {
|
|
114
|
-
return isManifestRegistration(target) ? target.definition : target;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function createFragment(text: string): ManifestConditionFragment {
|
|
118
|
-
return Object.freeze({ text });
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function skipWhitespace(state: RuntimeParsedConditionState): void {
|
|
122
|
-
while (state.index < state.text.length && /\s/.test(state.text[state.index] ?? '')) {
|
|
123
|
-
state.index += 1;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function consumeCharacter(state: RuntimeParsedConditionState, expected: string): boolean {
|
|
128
|
-
skipWhitespace(state);
|
|
129
|
-
if (state.text[state.index] === expected) {
|
|
130
|
-
state.index += 1;
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function expectCharacter(state: RuntimeParsedConditionState, expected: string): void {
|
|
137
|
-
if (!consumeCharacter(state, expected)) {
|
|
138
|
-
throw new Error(`Expected "${expected}" at index ${state.index}.`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function consumeKeyword(state: RuntimeParsedConditionState, keyword: string): boolean {
|
|
143
|
-
skipWhitespace(state);
|
|
144
|
-
const candidate = state.text.slice(state.index, state.index + keyword.length);
|
|
145
|
-
if (candidate.toUpperCase() !== keyword) return false;
|
|
146
|
-
|
|
147
|
-
const nextCharacter = state.text[state.index + keyword.length];
|
|
148
|
-
if (nextCharacter != null && /[A-Za-z0-9_]/.test(nextCharacter)) return false;
|
|
149
|
-
|
|
150
|
-
state.index += keyword.length;
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function parseIdentifier(state: RuntimeParsedConditionState): string {
|
|
155
|
-
skipWhitespace(state);
|
|
156
|
-
const start = state.index;
|
|
157
|
-
while (state.index < state.text.length && /[A-Za-z0-9_]/.test(state.text[state.index] ?? '')) {
|
|
158
|
-
state.index += 1;
|
|
159
|
-
}
|
|
160
|
-
if (state.index === start) {
|
|
161
|
-
throw new Error(`Expected a field or function identifier at index ${state.index}.`);
|
|
162
|
-
}
|
|
163
|
-
return state.text.slice(start, state.index);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function parseStringLiteral(state: RuntimeParsedConditionState): ParsedConditionStringLiteral {
|
|
167
|
-
expectCharacter(state, "'");
|
|
168
|
-
let value = '';
|
|
169
|
-
while (state.index < state.text.length) {
|
|
170
|
-
const character = state.text[state.index];
|
|
171
|
-
if (character === undefined) break;
|
|
172
|
-
state.index += 1;
|
|
173
|
-
if (character === "'") {
|
|
174
|
-
return { kind: 'string', value };
|
|
175
|
-
}
|
|
176
|
-
if (character === '\\') {
|
|
177
|
-
const escaped = state.text[state.index];
|
|
178
|
-
if (escaped == null) {
|
|
179
|
-
throw new Error('Unterminated escape sequence in manifest condition string literal.');
|
|
180
|
-
}
|
|
181
|
-
state.index += 1;
|
|
182
|
-
value += escaped;
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
value += character;
|
|
186
|
-
}
|
|
187
|
-
throw new Error('Unterminated manifest condition string literal.');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function parseNumberLiteral(state: RuntimeParsedConditionState): ParsedConditionNumberLiteral {
|
|
191
|
-
skipWhitespace(state);
|
|
192
|
-
const start = state.index;
|
|
193
|
-
if (state.text[state.index] === '-') {
|
|
194
|
-
state.index += 1;
|
|
195
|
-
}
|
|
196
|
-
let sawDigit = false;
|
|
197
|
-
while (state.index < state.text.length && /[0-9]/.test(state.text[state.index] ?? '')) {
|
|
198
|
-
state.index += 1;
|
|
199
|
-
sawDigit = true;
|
|
200
|
-
}
|
|
201
|
-
if (state.text[state.index] === '.') {
|
|
202
|
-
state.index += 1;
|
|
203
|
-
while (state.index < state.text.length && /[0-9]/.test(state.text[state.index] ?? '')) {
|
|
204
|
-
state.index += 1;
|
|
205
|
-
sawDigit = true;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (!sawDigit) {
|
|
209
|
-
throw new Error(`Expected a number literal at index ${start}.`);
|
|
210
|
-
}
|
|
211
|
-
const value = Number(state.text.slice(start, state.index));
|
|
212
|
-
if (!Number.isFinite(value)) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
`Manifest-condition numeric literals must be finite. Received ${state.text.slice(start, state.index)}.`,
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
return { kind: 'number', value };
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function parseScalarLiteral(
|
|
221
|
-
state: RuntimeParsedConditionState,
|
|
222
|
-
): ParsedConditionScalarLiteral | ParsedConditionFunctionLiteral {
|
|
223
|
-
skipWhitespace(state);
|
|
224
|
-
const character = state.text[state.index];
|
|
225
|
-
if (character === "'") return parseStringLiteral(state);
|
|
226
|
-
if (character === '-' || /[0-9]/.test(character ?? '')) return parseNumberLiteral(state);
|
|
227
|
-
if (consumeKeyword(state, 'TRUE')) return { kind: 'boolean', value: true };
|
|
228
|
-
if (consumeKeyword(state, 'FALSE')) return { kind: 'boolean', value: false };
|
|
229
|
-
if (consumeKeyword(state, 'NULL')) return { kind: 'null' };
|
|
230
|
-
if (consumeKeyword(state, 'TODAY')) {
|
|
231
|
-
expectCharacter(state, '(');
|
|
232
|
-
expectCharacter(state, ')');
|
|
233
|
-
return { kind: 'function', name: 'TODAY' };
|
|
234
|
-
}
|
|
235
|
-
throw new Error(`Expected a supported manifest-condition literal at index ${state.index}.`);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function parseArrayLiteral(state: RuntimeParsedConditionState): ParsedConditionArrayLiteral {
|
|
239
|
-
expectCharacter(state, '[');
|
|
240
|
-
const values: ParsedConditionScalarLiteral[] = [];
|
|
241
|
-
while (true) {
|
|
242
|
-
skipWhitespace(state);
|
|
243
|
-
if (consumeCharacter(state, ']')) {
|
|
244
|
-
return { kind: 'array', value: values };
|
|
245
|
-
}
|
|
246
|
-
const nextValue = parseScalarLiteral(state);
|
|
247
|
-
if (nextValue.kind === 'function') {
|
|
248
|
-
throw new Error('Manifest-condition arrays do not support TODAY().');
|
|
249
|
-
}
|
|
250
|
-
values.push(nextValue);
|
|
251
|
-
skipWhitespace(state);
|
|
252
|
-
if (consumeCharacter(state, ']')) {
|
|
253
|
-
return { kind: 'array', value: values };
|
|
254
|
-
}
|
|
255
|
-
expectCharacter(state, ',');
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function parseLiteral(state: RuntimeParsedConditionState): ParsedConditionLiteral {
|
|
260
|
-
skipWhitespace(state);
|
|
261
|
-
if (state.text[state.index] === '[') {
|
|
262
|
-
return parseArrayLiteral(state);
|
|
263
|
-
}
|
|
264
|
-
return parseScalarLiteral(state);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function parseOperator(state: RuntimeParsedConditionState): ParsedConditionComparisonNode['operator'] {
|
|
268
|
-
skipWhitespace(state);
|
|
269
|
-
for (const operator of ['NOT_IN', 'IN', '==', '!=', '<=', '>=', '<', '>'] as const) {
|
|
270
|
-
if (state.text.slice(state.index, state.index + operator.length).toUpperCase() === operator) {
|
|
271
|
-
state.index += operator.length;
|
|
272
|
-
return operator;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
throw new Error(`Expected a manifest-condition operator at index ${state.index}.`);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function parseComparison(state: RuntimeParsedConditionState): ParsedConditionComparisonNode {
|
|
279
|
-
const field = parseIdentifier(state);
|
|
280
|
-
const operator = parseOperator(state);
|
|
281
|
-
const value = parseLiteral(state);
|
|
282
|
-
return { kind: 'comparison', field, operator, value };
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function parsePrimary(state: RuntimeParsedConditionState): ParsedConditionExpressionNode {
|
|
286
|
-
skipWhitespace(state);
|
|
287
|
-
if (consumeCharacter(state, '(')) {
|
|
288
|
-
const expression = parseOrExpression(state);
|
|
289
|
-
expectCharacter(state, ')');
|
|
290
|
-
return expression;
|
|
291
|
-
}
|
|
292
|
-
return parseComparison(state);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function parseNotExpression(state: RuntimeParsedConditionState): ParsedConditionExpressionNode {
|
|
296
|
-
skipWhitespace(state);
|
|
297
|
-
if (consumeKeyword(state, 'NOT')) {
|
|
298
|
-
return { kind: 'not', operand: parseNotExpression(state) };
|
|
299
|
-
}
|
|
300
|
-
return parsePrimary(state);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function parseAndExpression(state: RuntimeParsedConditionState): ParsedConditionExpressionNode {
|
|
304
|
-
const operands: ParsedConditionExpressionNode[] = [parseNotExpression(state)];
|
|
305
|
-
while (true) {
|
|
306
|
-
const checkpoint = state.index;
|
|
307
|
-
if (!consumeKeyword(state, 'AND')) {
|
|
308
|
-
state.index = checkpoint;
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
operands.push(parseNotExpression(state));
|
|
312
|
-
}
|
|
313
|
-
return operands.length === 1 ? operands[0]! : { kind: 'logical', operator: 'AND', operands };
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function parseOrExpression(state: RuntimeParsedConditionState): ParsedConditionExpressionNode {
|
|
317
|
-
const operands: ParsedConditionExpressionNode[] = [parseAndExpression(state)];
|
|
318
|
-
while (true) {
|
|
319
|
-
const checkpoint = state.index;
|
|
320
|
-
if (!consumeKeyword(state, 'OR')) {
|
|
321
|
-
state.index = checkpoint;
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
operands.push(parseAndExpression(state));
|
|
325
|
-
}
|
|
326
|
-
return operands.length === 1 ? operands[0]! : { kind: 'logical', operator: 'OR', operands };
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function parseTypedConditionExpression(text: string): ParsedConditionExpressionNode {
|
|
330
|
-
const state: RuntimeParsedConditionState = { text, index: 0 };
|
|
331
|
-
const expression = parseOrExpression(state);
|
|
332
|
-
skipWhitespace(state);
|
|
333
|
-
if (state.index !== state.text.length) {
|
|
334
|
-
throw new Error(
|
|
335
|
-
`Unexpected trailing manifest-condition content starting at index ${state.index}: ${state.text.slice(
|
|
336
|
-
state.index,
|
|
337
|
-
)}.`,
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
return expression;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function resolveRuntimeFieldMetadata(
|
|
344
|
-
definition: AnyCustomObjectDefinition,
|
|
345
|
-
fieldName: string,
|
|
346
|
-
): RuntimeConditionFieldMetadata {
|
|
347
|
-
if ((STANDARD_TYPED_CONDITION_FIELDS as readonly string[]).includes(fieldName)) {
|
|
348
|
-
return {
|
|
349
|
-
apiName: fieldName,
|
|
350
|
-
category: STANDARD_TYPED_CONDITION_LOOKUP_FIELDS.has(fieldName) ? 'lookup' : 'string',
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const field = definition.fields[fieldName as FieldNames<typeof definition>];
|
|
355
|
-
if (field == null) {
|
|
356
|
-
throw new Error(
|
|
357
|
-
`Unknown manifest-condition field "${fieldName}" for "${definition.apiName}". Valid fields: ${[
|
|
358
|
-
...STANDARD_TYPED_CONDITION_FIELDS,
|
|
359
|
-
...Object.keys(definition.fields).sort(),
|
|
360
|
-
].join(', ')}.`,
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
switch (field.kind) {
|
|
365
|
-
case 'text':
|
|
366
|
-
case 'long-text':
|
|
367
|
-
case 'email':
|
|
368
|
-
case 'url':
|
|
369
|
-
case 'phone':
|
|
370
|
-
case 'date':
|
|
371
|
-
case 'datetime':
|
|
372
|
-
case 'time':
|
|
373
|
-
case 'select':
|
|
374
|
-
case 'radio':
|
|
375
|
-
case 'formula-text':
|
|
376
|
-
case 'formula-date':
|
|
377
|
-
case 'formula-url':
|
|
378
|
-
return { apiName: field.apiName, category: 'string' };
|
|
379
|
-
case 'number':
|
|
380
|
-
case 'currency':
|
|
381
|
-
case 'percentage':
|
|
382
|
-
case 'formula-number':
|
|
383
|
-
case 'formula-currency':
|
|
384
|
-
case 'formula-percentage':
|
|
385
|
-
return { apiName: field.apiName, category: 'number' };
|
|
386
|
-
case 'boolean':
|
|
387
|
-
case 'formula-boolean':
|
|
388
|
-
return { apiName: field.apiName, category: 'boolean' };
|
|
389
|
-
case 'lookup':
|
|
390
|
-
case 'parent-child':
|
|
391
|
-
return { apiName: field.apiName, category: 'lookup' };
|
|
392
|
-
default:
|
|
393
|
-
return { apiName: field.apiName, category: 'unsupported' };
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function encodeConditionString(value: string): string {
|
|
398
|
-
return `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function renderConditionLiteral(literal: ParsedConditionLiteral): string {
|
|
402
|
-
switch (literal.kind) {
|
|
403
|
-
case 'string':
|
|
404
|
-
return encodeConditionString(literal.value);
|
|
405
|
-
case 'number':
|
|
406
|
-
return String(literal.value);
|
|
407
|
-
case 'boolean':
|
|
408
|
-
return literal.value ? 'True' : 'False';
|
|
409
|
-
case 'null':
|
|
410
|
-
return 'null';
|
|
411
|
-
case 'function':
|
|
412
|
-
return `${literal.name}()`;
|
|
413
|
-
case 'array':
|
|
414
|
-
return `[${literal.value.map((value) => renderConditionLiteral(value)).join(', ')}]`;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function describeExpectedLiteral(category: ManifestConditionCategory): string {
|
|
419
|
-
switch (category) {
|
|
420
|
-
case 'string':
|
|
421
|
-
return "a quoted string literal such as 'Ada' or TODAY()";
|
|
422
|
-
case 'number':
|
|
423
|
-
return 'a numeric literal such as 14';
|
|
424
|
-
case 'boolean':
|
|
425
|
-
return 'a boolean literal: True or False';
|
|
426
|
-
case 'lookup':
|
|
427
|
-
return "a quoted record-id string such as 'role_123'";
|
|
428
|
-
default:
|
|
429
|
-
return 'a supported literal value';
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function describeLiteral(literal: ParsedConditionLiteral): string {
|
|
434
|
-
switch (literal.kind) {
|
|
435
|
-
case 'string':
|
|
436
|
-
return `quoted string ${encodeConditionString(literal.value)}`;
|
|
437
|
-
case 'number':
|
|
438
|
-
return `number ${String(literal.value)}`;
|
|
439
|
-
case 'boolean':
|
|
440
|
-
return `boolean ${literal.value ? 'True' : 'False'}`;
|
|
441
|
-
case 'null':
|
|
442
|
-
return 'null';
|
|
443
|
-
case 'function':
|
|
444
|
-
return `${literal.name}()`;
|
|
445
|
-
case 'array':
|
|
446
|
-
return `array ${renderConditionLiteral(literal)}`;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function assertLiteralMatchesCategory(
|
|
451
|
-
fieldName: string,
|
|
452
|
-
category: ManifestConditionCategory,
|
|
453
|
-
operator: ParsedConditionComparisonNode['operator'],
|
|
454
|
-
literal: ParsedConditionLiteral,
|
|
455
|
-
): void {
|
|
456
|
-
if (category === 'unsupported') {
|
|
457
|
-
throw new Error('typedCondition(...) does not yet support this field kind in parsed-string mode.');
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
if (operator === 'IN' || operator === 'NOT_IN') {
|
|
461
|
-
if (literal.kind !== 'array') {
|
|
462
|
-
throw new Error(
|
|
463
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" requires an array literal such as ['value']; received ${describeLiteral(
|
|
464
|
-
literal,
|
|
465
|
-
)}.`,
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
|
-
if (literal.value.length === 0) {
|
|
469
|
-
throw new Error(
|
|
470
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" requires a non-empty array literal such as ['value'].`,
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
for (const value of literal.value) {
|
|
474
|
-
assertLiteralMatchesCategory(fieldName, category, '==', value);
|
|
475
|
-
}
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (literal.kind === 'null') {
|
|
480
|
-
if (operator === '<' || operator === '<=' || operator === '>' || operator === '>=') {
|
|
481
|
-
throw new Error(
|
|
482
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" does not allow null. Use a concrete ${describeExpectedLiteral(
|
|
483
|
-
category,
|
|
484
|
-
)}.`,
|
|
485
|
-
);
|
|
486
|
-
}
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
if (literal.kind === 'function') {
|
|
491
|
-
if (literal.name !== 'TODAY' || category !== 'string') {
|
|
492
|
-
throw new Error(
|
|
493
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" does not support ${describeLiteral(
|
|
494
|
-
literal,
|
|
495
|
-
)}.`,
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
if (
|
|
502
|
-
(operator === '<' || operator === '<=' || operator === '>' || operator === '>=') &&
|
|
503
|
-
!(category === 'string' || category === 'number')
|
|
504
|
-
) {
|
|
505
|
-
throw new Error(
|
|
506
|
-
`Manifest-condition field "${fieldName}" uses operator "${operator}", which is only valid for string or number fields; this field expects ${describeExpectedLiteral(
|
|
507
|
-
category,
|
|
508
|
-
)}.`,
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
switch (category) {
|
|
513
|
-
case 'string':
|
|
514
|
-
if (literal.kind !== 'string') {
|
|
515
|
-
throw new Error(
|
|
516
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" expects ${describeExpectedLiteral(
|
|
517
|
-
category,
|
|
518
|
-
)}; received ${describeLiteral(literal)}.`,
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
return;
|
|
522
|
-
case 'number':
|
|
523
|
-
if (literal.kind !== 'number') {
|
|
524
|
-
throw new Error(
|
|
525
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" expects ${describeExpectedLiteral(
|
|
526
|
-
category,
|
|
527
|
-
)}; received ${describeLiteral(literal)}.`,
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
return;
|
|
531
|
-
case 'boolean':
|
|
532
|
-
if (literal.kind !== 'boolean') {
|
|
533
|
-
throw new Error(
|
|
534
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" expects ${describeExpectedLiteral(
|
|
535
|
-
category,
|
|
536
|
-
)}; received ${describeLiteral(literal)}.`,
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
return;
|
|
540
|
-
case 'lookup':
|
|
541
|
-
if (literal.kind !== 'string') {
|
|
542
|
-
throw new Error(
|
|
543
|
-
`Manifest-condition field "${fieldName}" with operator "${operator}" expects ${describeExpectedLiteral(
|
|
544
|
-
category,
|
|
545
|
-
)}; received ${describeLiteral(literal)}.`,
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
return;
|
|
549
|
-
default:
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function validateTypedConditionAst(
|
|
555
|
-
definition: AnyCustomObjectDefinition,
|
|
556
|
-
node: ParsedConditionExpressionNode,
|
|
557
|
-
): void {
|
|
558
|
-
switch (node.kind) {
|
|
559
|
-
case 'logical':
|
|
560
|
-
for (const operand of node.operands) validateTypedConditionAst(definition, operand);
|
|
561
|
-
return;
|
|
562
|
-
case 'not':
|
|
563
|
-
validateTypedConditionAst(definition, node.operand);
|
|
564
|
-
return;
|
|
565
|
-
case 'comparison': {
|
|
566
|
-
const metadata = resolveRuntimeFieldMetadata(definition, node.field);
|
|
567
|
-
assertLiteralMatchesCategory(node.field, metadata.category, node.operator, node.value);
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
function renderTypedConditionAst(
|
|
574
|
-
definition: AnyCustomObjectDefinition,
|
|
575
|
-
node: ParsedConditionExpressionNode,
|
|
576
|
-
): string {
|
|
577
|
-
switch (node.kind) {
|
|
578
|
-
case 'logical':
|
|
579
|
-
return `(${node.operands
|
|
580
|
-
.map((operand) => renderTypedConditionAst(definition, operand))
|
|
581
|
-
.join(` ${node.operator} `)})`;
|
|
582
|
-
case 'not':
|
|
583
|
-
return `(NOT ${renderTypedConditionAst(definition, node.operand)})`;
|
|
584
|
-
case 'comparison': {
|
|
585
|
-
const metadata = resolveRuntimeFieldMetadata(definition, node.field);
|
|
586
|
-
return `(${metadata.apiName} ${node.operator} ${renderConditionLiteral(node.value)})`;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Parses one constrained logical-name manifest-condition string, validates it against the typed custom-object definition,
|
|
593
|
-
* and renders a backend-ready manifest condition that uses wire-level field API names.
|
|
594
|
-
*
|
|
595
|
-
* Supported parsed-string manifest-condition contract:
|
|
596
|
-
* - standard record fields and local custom-object fields
|
|
597
|
-
* - `==`, `!=`, `<`, `<=`, `>`, `>=`, `IN`, `NOT_IN`
|
|
598
|
-
* - `AND`, `OR`, `NOT`
|
|
599
|
-
* - parentheses / grouping
|
|
600
|
-
* - string / number / boolean / null / array literals
|
|
601
|
-
* - `TODAY()`
|
|
602
|
-
*
|
|
603
|
-
* @param target - Object definition or manifest registration whose logical field names should be enforced.
|
|
604
|
-
* @param expression - Constrained logical-name manifest-condition source string to parse and render.
|
|
605
|
-
* @returns Opaque manifest-condition fragment that can be passed anywhere typed manifest helpers accept conditions.
|
|
606
|
-
* @typeParam TDefinition - Object definition whose field names and value categories should be enforced.
|
|
607
|
-
* @typeParam TExpression - Candidate manifest-condition expression string.
|
|
608
|
-
*/
|
|
609
|
-
export function typedCondition<TDefinition extends AnyCustomObjectDefinition, TExpression extends string>(
|
|
610
|
-
target: ManifestCustomObjectTarget<TDefinition>,
|
|
611
|
-
expression: TExpression,
|
|
612
|
-
): ManifestConditionFragment {
|
|
613
|
-
const definition = resolveTargetDefinition(target);
|
|
614
|
-
const ast = parseTypedConditionExpression(expression as string);
|
|
615
|
-
validateTypedConditionAst(definition, ast);
|
|
616
|
-
return createFragment(renderTypedConditionAst(definition, ast));
|
|
617
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Category,
|
|
3
|
-
CustomObject,
|
|
4
|
-
CustomObjectFieldSection,
|
|
5
|
-
BooleanField,
|
|
6
|
-
CurrencyField,
|
|
7
|
-
DateField,
|
|
8
|
-
DatetimeField,
|
|
9
|
-
EmailField,
|
|
10
|
-
FileField,
|
|
11
|
-
FormulaField,
|
|
12
|
-
LongTextField,
|
|
13
|
-
LookupField,
|
|
14
|
-
NumberField,
|
|
15
|
-
ParentChildField,
|
|
16
|
-
PercentageField,
|
|
17
|
-
PhoneField,
|
|
18
|
-
RadioField,
|
|
19
|
-
SelectField,
|
|
20
|
-
TextField,
|
|
21
|
-
TimeField,
|
|
22
|
-
UrlField,
|
|
23
|
-
} from '../../../../lib/manifest';
|
|
24
|
-
import type {
|
|
25
|
-
AnyCustomObjectDefinition,
|
|
26
|
-
BooleanFieldDefinition,
|
|
27
|
-
CurrencyFieldDefinition,
|
|
28
|
-
DateFieldDefinition,
|
|
29
|
-
DatetimeFieldDefinition,
|
|
30
|
-
EmailFieldDefinition,
|
|
31
|
-
FieldNames,
|
|
32
|
-
FileFieldDefinition,
|
|
33
|
-
FormulaFieldDefinition,
|
|
34
|
-
LongTextFieldDefinition,
|
|
35
|
-
LookupFieldDefinition,
|
|
36
|
-
NumberFieldDefinition,
|
|
37
|
-
ParentChildFieldDefinition,
|
|
38
|
-
PercentageFieldDefinition,
|
|
39
|
-
PhoneFieldDefinition,
|
|
40
|
-
RadioFieldDefinition,
|
|
41
|
-
SelectFieldDefinition,
|
|
42
|
-
TextFieldDefinition,
|
|
43
|
-
TimeFieldDefinition,
|
|
44
|
-
UrlFieldDefinition,
|
|
45
|
-
} from '../../custom-objects/types';
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Runtime compilation result for the typed custom-object manifest adapter.
|
|
49
|
-
*
|
|
50
|
-
* The return type preserves both logical field keys and concrete manifest field
|
|
51
|
-
* classes so authors can continue using the existing manifest APIs while the
|
|
52
|
-
* typed schema layer owns wire-level naming details.
|
|
53
|
-
*
|
|
54
|
-
* @typeParam TDefinition - Object definition that was materialized into manifest classes.
|
|
55
|
-
*/
|
|
56
|
-
export interface ManifestRegistration<TDefinition extends AnyCustomObjectDefinition> {
|
|
57
|
-
readonly definition: TDefinition;
|
|
58
|
-
readonly category: Category;
|
|
59
|
-
readonly object: CustomObject;
|
|
60
|
-
readonly sections: {
|
|
61
|
-
readonly [K in Extract<keyof TDefinition['sections'], string>]: CustomObjectFieldSection;
|
|
62
|
-
};
|
|
63
|
-
readonly fields: {
|
|
64
|
-
readonly [K in FieldNames<TDefinition>]: ManifestFieldForDefinition<TDefinition['fields'][K]>;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Maps a typed field definition to the concrete manifest field class it compiles into.
|
|
70
|
-
*
|
|
71
|
-
* @typeParam TField - Field definition that should be translated into a manifest class.
|
|
72
|
-
*/
|
|
73
|
-
export type ManifestFieldForDefinition<TField> =
|
|
74
|
-
TField extends TextFieldDefinition<any, any> ? TextField
|
|
75
|
-
: TField extends LongTextFieldDefinition<any, any> ? LongTextField
|
|
76
|
-
: TField extends EmailFieldDefinition<any, any> ? EmailField
|
|
77
|
-
: TField extends UrlFieldDefinition<any, any> ? UrlField
|
|
78
|
-
: TField extends PhoneFieldDefinition<any, any> ? PhoneField
|
|
79
|
-
: TField extends NumberFieldDefinition<any, any> ? NumberField
|
|
80
|
-
: TField extends CurrencyFieldDefinition<any, any> ? CurrencyField
|
|
81
|
-
: TField extends PercentageFieldDefinition<any, any> ? PercentageField
|
|
82
|
-
: TField extends DateFieldDefinition<any, any> ? DateField
|
|
83
|
-
: TField extends DatetimeFieldDefinition<any, any> ? DatetimeField
|
|
84
|
-
: TField extends TimeFieldDefinition<any, any> ? TimeField
|
|
85
|
-
: TField extends SelectFieldDefinition<any, any> ? SelectField
|
|
86
|
-
: TField extends RadioFieldDefinition<any, any> ? RadioField
|
|
87
|
-
: TField extends BooleanFieldDefinition<any, any> ? BooleanField
|
|
88
|
-
: TField extends FileFieldDefinition<any, any> ? FileField
|
|
89
|
-
: TField extends LookupFieldDefinition<any, any, any> ? LookupField
|
|
90
|
-
: TField extends ParentChildFieldDefinition<any, any> ? ParentChildField
|
|
91
|
-
: TField extends FormulaFieldDefinition<any, any, any> ? FormulaField
|
|
92
|
-
: never;
|