@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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* In `triggerFunction`, server-bound action params live under `inputs` so
|
|
12
12
|
* repeated item values like `todo.$('id')` resolve before reaching
|
|
13
|
-
* `event['parameters']`. Client-side controls such as `
|
|
13
|
+
* `event['parameters']`. Client-side controls such as `functionApiName`,
|
|
14
14
|
* `responsePath`, `onSuccess`, and `onError` stay top-level.
|
|
15
15
|
*
|
|
16
16
|
* `/isMutating` is a shared loading flag: it disables every action while an API
|
|
@@ -29,31 +29,23 @@ import {
|
|
|
29
29
|
TextInput,
|
|
30
30
|
VStack,
|
|
31
31
|
render,
|
|
32
|
+
setState,
|
|
33
|
+
triggerFunction,
|
|
32
34
|
} from '@rippling/pebble-sdui-web/catalogs/custom-apps';
|
|
33
|
-
import
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
createTypedSduiMutationTrigger,
|
|
42
|
-
defineTypedSduiPageHandlerFor,
|
|
43
|
-
defineTypedSduiStateAssignments,
|
|
44
|
-
resolveTypedSduiStatePath,
|
|
45
|
-
type TypedSduiPageActionParams,
|
|
46
|
-
type TypedSduiPageOutput,
|
|
47
|
-
} from '@rippling/rippling-sdk/core/platform/manifest/custom-objects';
|
|
48
|
-
import { todoDefinition } from '../schema';
|
|
49
|
-
|
|
50
|
-
const todoRql = createRqlHelpers(todoDefinition);
|
|
35
|
+
import RipplingSDK, {
|
|
36
|
+
FunctionContext,
|
|
37
|
+
FunctionResponse,
|
|
38
|
+
SduiPageFunctionEvent,
|
|
39
|
+
} from '@rippling/rippling-sdk';
|
|
40
|
+
import type { CustomObjectDataRow } from '@rippling/rippling-sdk/resources/custom-objects/records';
|
|
41
|
+
|
|
42
|
+
const OBJECT_API_NAME = 'todo__c';
|
|
51
43
|
type TodoPageAction = 'init' | 'addTodo' | 'toggleTodo' | 'clearCompleted';
|
|
52
|
-
type TodoPageFunctionParameters =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
type TodoPageFunctionParameters = {
|
|
45
|
+
action: TodoPageAction;
|
|
46
|
+
text?: string;
|
|
47
|
+
todoId?: string;
|
|
48
|
+
};
|
|
57
49
|
|
|
58
50
|
type Todo = {
|
|
59
51
|
id: string;
|
|
@@ -61,8 +53,6 @@ type Todo = {
|
|
|
61
53
|
completed: boolean;
|
|
62
54
|
};
|
|
63
55
|
|
|
64
|
-
type TodoRecord = RecordShape<typeof todoDefinition>;
|
|
65
|
-
|
|
66
56
|
type TodoListState = {
|
|
67
57
|
todos: Todo[];
|
|
68
58
|
isEmpty: boolean;
|
|
@@ -77,43 +67,27 @@ type TodoAppState = {
|
|
|
77
67
|
|
|
78
68
|
type TodoSpec = SpecContext<TodoAppState>;
|
|
79
69
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
todoListTodos: todoStatePath('/todoList/todos'),
|
|
85
|
-
todoListIsEmpty: todoStatePath('/todoList/isEmpty'),
|
|
86
|
-
isMutating: todoStatePath('/isMutating'),
|
|
87
|
-
errorMessage: todoStatePath('/errorMessage'),
|
|
88
|
-
} as const;
|
|
89
|
-
|
|
90
|
-
export type Input = SduiPageFunctionEvent<TodoPageFunctionParameters>;
|
|
91
|
-
|
|
92
|
-
export type Output = TypedSduiPageOutput<TodoListState>;
|
|
93
|
-
|
|
94
|
-
function createTodoManager(context: FunctionContext): TypedCustomObjectRecordManager<typeof todoDefinition> {
|
|
95
|
-
const runtime = createCustomObjectFunctionRuntime(context);
|
|
96
|
-
return runtime.for(todoDefinition);
|
|
70
|
+
function createClient(context: FunctionContext): RipplingSDK {
|
|
71
|
+
return new RipplingSDK({
|
|
72
|
+
bearerToken: context.env.rippling_user_bearer_token,
|
|
73
|
+
});
|
|
97
74
|
}
|
|
98
75
|
|
|
99
|
-
function toTodo(record:
|
|
76
|
+
function toTodo(record: CustomObjectDataRow): Todo {
|
|
100
77
|
return {
|
|
101
78
|
id: record.id,
|
|
102
79
|
text: record.name,
|
|
103
|
-
completed: record
|
|
80
|
+
completed: record['completed__c'] === true,
|
|
104
81
|
};
|
|
105
82
|
}
|
|
106
83
|
|
|
107
|
-
async function listTodos(
|
|
108
|
-
|
|
109
|
-
roleId: string,
|
|
110
|
-
): Promise<Todo[]> {
|
|
111
|
-
const response = await manager.query({
|
|
84
|
+
async function listTodos(client: RipplingSDK, roleId: string): Promise<Todo[]> {
|
|
85
|
+
const response = await client.customObjects.records.query(OBJECT_API_NAME, {
|
|
112
86
|
limit: 100,
|
|
113
|
-
query:
|
|
87
|
+
query: `created_by = "${roleId}"`, // RQL query to filter todos by the current role
|
|
114
88
|
});
|
|
115
89
|
|
|
116
|
-
return response.results.map(toTodo);
|
|
90
|
+
return (response.results ?? []).map(toTodo);
|
|
117
91
|
}
|
|
118
92
|
|
|
119
93
|
function todoListState(todos: Todo[]): TodoListState {
|
|
@@ -132,32 +106,49 @@ function todoState(todos: Todo[]): TodoAppState {
|
|
|
132
106
|
};
|
|
133
107
|
}
|
|
134
108
|
|
|
135
|
-
function
|
|
136
|
-
return
|
|
109
|
+
function ok(body: Record<string, unknown> | unknown[] = {}): FunctionResponse {
|
|
110
|
+
return new FunctionResponse({
|
|
111
|
+
body: body as Record<string, unknown>,
|
|
112
|
+
statusCode: 200,
|
|
113
|
+
headers: {},
|
|
114
|
+
message: '',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function badRequest(message: string): FunctionResponse {
|
|
119
|
+
return new FunctionResponse({
|
|
120
|
+
body: { error: message },
|
|
121
|
+
statusCode: 400,
|
|
122
|
+
headers: {},
|
|
123
|
+
message,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function serverError(error: unknown): FunctionResponse {
|
|
128
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
129
|
+
|
|
130
|
+
return new FunctionResponse({
|
|
131
|
+
body: { error: message },
|
|
132
|
+
statusCode: 500,
|
|
133
|
+
headers: {},
|
|
134
|
+
message,
|
|
135
|
+
});
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
function
|
|
140
|
-
|
|
138
|
+
function stringParam(params: TodoPageFunctionParameters, key: 'text' | 'todoId'): string {
|
|
139
|
+
const value = params[key];
|
|
140
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
) {
|
|
149
|
-
return createTypedSduiMutationTrigger<TodoAppState, TodoListState, typeof inputs>({
|
|
150
|
-
functionId,
|
|
151
|
-
inputs,
|
|
152
|
-
responsePath: todoStatePaths.todoList,
|
|
153
|
-
errorMessage,
|
|
154
|
-
mutationStatePath: todoStatePaths.isMutating,
|
|
155
|
-
errorStatePath: todoStatePaths.errorMessage,
|
|
156
|
-
...(onSuccessState != null ? { onSuccessState } : {}),
|
|
143
|
+
// A single mutation flag disables all actions and drives the visible loading text.
|
|
144
|
+
function setMutationState(isMutating: boolean) {
|
|
145
|
+
return setState({
|
|
146
|
+
statePath: '/isMutating',
|
|
147
|
+
value: isMutating,
|
|
157
148
|
});
|
|
158
149
|
}
|
|
159
150
|
|
|
160
|
-
function buildAddTodoSection(spec: TodoSpec,
|
|
151
|
+
function buildAddTodoSection(spec: TodoSpec, functionApiName: string) {
|
|
161
152
|
return VStack({
|
|
162
153
|
id: 'addTodoSection',
|
|
163
154
|
props: {},
|
|
@@ -173,8 +164,8 @@ function buildAddTodoSection(spec: TodoSpec, functionId: string) {
|
|
|
173
164
|
props: {
|
|
174
165
|
name: 'newTodo',
|
|
175
166
|
placeholder: 'Enter a new todo item',
|
|
176
|
-
value: spec.$bindState(
|
|
177
|
-
isDisabled: spec.$state(
|
|
167
|
+
value: spec.$bindState('/newTodoText'),
|
|
168
|
+
isDisabled: spec.$state('/isMutating'),
|
|
178
169
|
},
|
|
179
170
|
}),
|
|
180
171
|
],
|
|
@@ -186,34 +177,37 @@ function buildAddTodoSection(spec: TodoSpec, functionId: string) {
|
|
|
186
177
|
appearance: 'PRIMARY',
|
|
187
178
|
isFluid: true,
|
|
188
179
|
isDisabled: spec.$cond(
|
|
189
|
-
or_(
|
|
190
|
-
equals(spec.$state(todoStatePaths.newTodoText), ''),
|
|
191
|
-
equals(spec.$state(todoStatePaths.isMutating), true),
|
|
192
|
-
),
|
|
180
|
+
or_(equals(spec.$state('/newTodoText'), ''), equals(spec.$state('/isMutating'), true)),
|
|
193
181
|
true,
|
|
194
182
|
false,
|
|
195
183
|
),
|
|
196
184
|
},
|
|
197
185
|
on: {
|
|
198
|
-
press:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
186
|
+
press: [
|
|
187
|
+
setMutationState(true),
|
|
188
|
+
triggerFunction(
|
|
189
|
+
{
|
|
190
|
+
functionApiName,
|
|
191
|
+
inputs: {
|
|
192
|
+
action: 'addTodo',
|
|
193
|
+
text: spec.$state('/newTodoText'),
|
|
194
|
+
},
|
|
195
|
+
responsePath: '/todoList',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
onSuccess: { set: { '/newTodoText': '', '/errorMessage': '', '/isMutating': false } },
|
|
199
|
+
onError: { set: { '/errorMessage': 'Could not add todo. Try again.', '/isMutating': false } },
|
|
200
|
+
},
|
|
201
|
+
),
|
|
202
|
+
],
|
|
209
203
|
},
|
|
210
204
|
}),
|
|
211
205
|
],
|
|
212
206
|
});
|
|
213
207
|
}
|
|
214
208
|
|
|
215
|
-
function buildTodoItems(spec: TodoSpec,
|
|
216
|
-
const [todoRepeat, todo] = spec.repeat(
|
|
209
|
+
function buildTodoItems(spec: TodoSpec, functionApiName: string) {
|
|
210
|
+
const [todoRepeat, todo] = spec.repeat('/todoList/todos', 'id');
|
|
217
211
|
|
|
218
212
|
return VStack({
|
|
219
213
|
id: 'todoItems',
|
|
@@ -237,17 +231,31 @@ function buildTodoItems(spec: TodoSpec, functionId: string) {
|
|
|
237
231
|
props: {
|
|
238
232
|
name: 'completed',
|
|
239
233
|
value: todo.$bind('completed'),
|
|
240
|
-
isDisabled: spec.$state(
|
|
234
|
+
isDisabled: spec.$state('/isMutating'),
|
|
241
235
|
},
|
|
242
236
|
on: {
|
|
243
|
-
change:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
237
|
+
change: [
|
|
238
|
+
setMutationState(true),
|
|
239
|
+
triggerFunction(
|
|
240
|
+
{
|
|
241
|
+
functionApiName,
|
|
242
|
+
inputs: {
|
|
243
|
+
action: 'toggleTodo',
|
|
244
|
+
todoId: todo.$('id'),
|
|
245
|
+
},
|
|
246
|
+
responsePath: '/todoList',
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
onSuccess: { set: { '/errorMessage': '', '/isMutating': false } },
|
|
250
|
+
onError: {
|
|
251
|
+
set: {
|
|
252
|
+
'/errorMessage': 'Could not update todo. Refresh and try again.',
|
|
253
|
+
'/isMutating': false,
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
),
|
|
258
|
+
],
|
|
251
259
|
},
|
|
252
260
|
}),
|
|
253
261
|
Text({
|
|
@@ -264,7 +272,7 @@ function buildTodoItems(spec: TodoSpec, functionId: string) {
|
|
|
264
272
|
});
|
|
265
273
|
}
|
|
266
274
|
|
|
267
|
-
function buildTodoList(spec: TodoSpec,
|
|
275
|
+
function buildTodoList(spec: TodoSpec, functionApiName: string) {
|
|
268
276
|
return VStack({
|
|
269
277
|
id: 'todoList',
|
|
270
278
|
props: {
|
|
@@ -293,35 +301,46 @@ function buildTodoList(spec: TodoSpec, functionId: string) {
|
|
|
293
301
|
appearance: 'OUTLINE',
|
|
294
302
|
size: 'S',
|
|
295
303
|
isDisabled: spec.$cond(
|
|
296
|
-
or_(
|
|
297
|
-
equals(spec.$state(todoStatePaths.isMutating), true),
|
|
298
|
-
equals(spec.$state(todoStatePaths.todoListIsEmpty), true),
|
|
299
|
-
),
|
|
304
|
+
or_(equals(spec.$state('/isMutating'), true), equals(spec.$state('/todoList/isEmpty'), true)),
|
|
300
305
|
true,
|
|
301
306
|
false,
|
|
302
307
|
),
|
|
303
308
|
},
|
|
304
309
|
on: {
|
|
305
|
-
press:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
press: [
|
|
311
|
+
setMutationState(true),
|
|
312
|
+
triggerFunction(
|
|
313
|
+
{
|
|
314
|
+
functionApiName,
|
|
315
|
+
inputs: {
|
|
316
|
+
action: 'clearCompleted',
|
|
317
|
+
},
|
|
318
|
+
responsePath: '/todoList',
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
onSuccess: { set: { '/errorMessage': '', '/isMutating': false } },
|
|
322
|
+
onError: {
|
|
323
|
+
set: {
|
|
324
|
+
'/errorMessage': 'Could not clear completed todos. Try again.',
|
|
325
|
+
'/isMutating': false,
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
),
|
|
330
|
+
],
|
|
312
331
|
},
|
|
313
332
|
}),
|
|
314
333
|
],
|
|
315
334
|
}),
|
|
316
335
|
Text({
|
|
317
336
|
id: 'emptyTodos',
|
|
318
|
-
visible: equals(spec.$state(
|
|
337
|
+
visible: equals(spec.$state('/todoList/isEmpty'), true),
|
|
319
338
|
props: {
|
|
320
339
|
text: 'No todos yet.',
|
|
321
340
|
color: 'colorOnSurfaceVariant',
|
|
322
341
|
},
|
|
323
342
|
}),
|
|
324
|
-
buildTodoItems(spec,
|
|
343
|
+
buildTodoItems(spec, functionApiName),
|
|
325
344
|
],
|
|
326
345
|
});
|
|
327
346
|
}
|
|
@@ -329,9 +348,9 @@ function buildTodoList(spec: TodoSpec, functionId: string) {
|
|
|
329
348
|
function buildError(spec: TodoSpec) {
|
|
330
349
|
return Text({
|
|
331
350
|
id: 'todoError',
|
|
332
|
-
visible: neq(spec.$state(
|
|
351
|
+
visible: neq(spec.$state('/errorMessage'), ''),
|
|
333
352
|
props: {
|
|
334
|
-
text: spec.$state(
|
|
353
|
+
text: spec.$state('/errorMessage'),
|
|
335
354
|
color: 'colorError',
|
|
336
355
|
},
|
|
337
356
|
});
|
|
@@ -341,7 +360,7 @@ function buildLoading(spec: TodoSpec) {
|
|
|
341
360
|
return Text({
|
|
342
361
|
id: 'todoLoading',
|
|
343
362
|
// Keep disabled controls explainable while a triggerFunction call is in flight.
|
|
344
|
-
visible: equals(spec.$state(
|
|
363
|
+
visible: equals(spec.$state('/isMutating'), true),
|
|
345
364
|
props: {
|
|
346
365
|
text: 'Updating todos...',
|
|
347
366
|
color: 'colorOnSurfaceVariant',
|
|
@@ -349,7 +368,7 @@ function buildLoading(spec: TodoSpec) {
|
|
|
349
368
|
});
|
|
350
369
|
}
|
|
351
370
|
|
|
352
|
-
function buildTodoCard(spec: TodoSpec,
|
|
371
|
+
function buildTodoCard(spec: TodoSpec, functionApiName: string) {
|
|
353
372
|
return Card({
|
|
354
373
|
id: 'todoCard',
|
|
355
374
|
props: {},
|
|
@@ -361,17 +380,17 @@ function buildTodoCard(spec: TodoSpec, functionId: string) {
|
|
|
361
380
|
padding: 'space400',
|
|
362
381
|
},
|
|
363
382
|
children: [
|
|
364
|
-
buildAddTodoSection(spec,
|
|
383
|
+
buildAddTodoSection(spec, functionApiName),
|
|
365
384
|
buildError(spec),
|
|
366
385
|
buildLoading(spec),
|
|
367
|
-
buildTodoList(spec,
|
|
386
|
+
buildTodoList(spec, functionApiName),
|
|
368
387
|
],
|
|
369
388
|
}),
|
|
370
389
|
],
|
|
371
390
|
});
|
|
372
391
|
}
|
|
373
392
|
|
|
374
|
-
function renderSpec(state: TodoAppState,
|
|
393
|
+
function renderSpec(state: TodoAppState, functionApiName: string) {
|
|
375
394
|
const spec = createSpec<TodoAppState>({ state });
|
|
376
395
|
const root = PageContent({
|
|
377
396
|
id: 'todoApp',
|
|
@@ -379,92 +398,100 @@ function renderSpec(state: TodoAppState, functionId: string) {
|
|
|
379
398
|
size: '776',
|
|
380
399
|
alignment: 'CENTER',
|
|
381
400
|
},
|
|
382
|
-
children: [buildTodoCard(spec,
|
|
401
|
+
children: [buildTodoCard(spec, functionApiName)],
|
|
383
402
|
});
|
|
384
403
|
|
|
385
404
|
return render({ root, state });
|
|
386
405
|
}
|
|
387
406
|
|
|
388
407
|
async function addTodo(
|
|
389
|
-
|
|
390
|
-
params:
|
|
408
|
+
client: RipplingSDK,
|
|
409
|
+
params: TodoPageFunctionParameters,
|
|
391
410
|
roleId: string,
|
|
392
411
|
): Promise<TodoListState> {
|
|
393
|
-
const text =
|
|
412
|
+
const text = stringParam(params, 'text');
|
|
394
413
|
|
|
395
414
|
if (!text) {
|
|
396
415
|
throw new Error('Todo text is required');
|
|
397
416
|
}
|
|
398
417
|
|
|
399
|
-
await
|
|
418
|
+
await client.customObjects.records.create(OBJECT_API_NAME, {
|
|
400
419
|
name: text,
|
|
401
|
-
|
|
420
|
+
completed__c: false,
|
|
402
421
|
});
|
|
403
422
|
|
|
404
|
-
return todoListState(await listTodos(
|
|
423
|
+
return todoListState(await listTodos(client, roleId));
|
|
405
424
|
}
|
|
406
425
|
|
|
407
426
|
async function toggleTodo(
|
|
408
|
-
|
|
409
|
-
params:
|
|
427
|
+
client: RipplingSDK,
|
|
428
|
+
params: TodoPageFunctionParameters,
|
|
410
429
|
roleId: string,
|
|
411
430
|
): Promise<TodoListState> {
|
|
412
|
-
const todoId =
|
|
431
|
+
const todoId = stringParam(params, 'todoId');
|
|
413
432
|
|
|
414
433
|
if (!todoId) {
|
|
415
434
|
throw new Error('todoId must be a todo record ID');
|
|
416
435
|
}
|
|
417
436
|
|
|
418
|
-
const todo = toTodo(await
|
|
419
|
-
await
|
|
420
|
-
|
|
437
|
+
const todo = toTodo(await client.customObjects.records.retrieve(OBJECT_API_NAME, todoId));
|
|
438
|
+
await client.customObjects.records.update(OBJECT_API_NAME, todoId, {
|
|
439
|
+
completed__c: !todo.completed,
|
|
421
440
|
});
|
|
422
441
|
|
|
423
|
-
return todoListState(await listTodos(
|
|
442
|
+
return todoListState(await listTodos(client, roleId));
|
|
424
443
|
}
|
|
425
444
|
|
|
426
|
-
async function clearCompleted(
|
|
427
|
-
|
|
428
|
-
roleId: string,
|
|
429
|
-
): Promise<TodoListState> {
|
|
430
|
-
const todos = await listTodos(manager, roleId);
|
|
445
|
+
async function clearCompleted(client: RipplingSDK, roleId: string): Promise<TodoListState> {
|
|
446
|
+
const todos = await listTodos(client, roleId);
|
|
431
447
|
const completedTodoIds = todos.filter((todo) => todo.completed).map((todo) => todo.id);
|
|
432
448
|
|
|
433
449
|
if (completedTodoIds.length === 0) {
|
|
434
450
|
return todoListState(todos);
|
|
435
451
|
}
|
|
436
452
|
|
|
437
|
-
await
|
|
438
|
-
|
|
453
|
+
await client.customObjects.records.bulkDelete(OBJECT_API_NAME, {
|
|
454
|
+
all_or_nothing: false,
|
|
455
|
+
rows_to_delete: completedTodoIds,
|
|
439
456
|
});
|
|
440
457
|
|
|
441
|
-
return todoListState(await listTodos(
|
|
458
|
+
return todoListState(await listTodos(client, roleId));
|
|
442
459
|
}
|
|
443
460
|
|
|
444
|
-
const defineTodoPageHandler = defineTypedSduiPageHandlerFor<TodoPageFunctionParameters, TodoListState>();
|
|
445
|
-
|
|
446
|
-
const todoPageHandler = defineTodoPageHandler({
|
|
447
|
-
requireRoleId: true,
|
|
448
|
-
createRuntime(context) {
|
|
449
|
-
return {
|
|
450
|
-
manager: createTodoManager(context),
|
|
451
|
-
functionId: context.function.function_id,
|
|
452
|
-
};
|
|
453
|
-
},
|
|
454
|
-
async init({ runtime, roleId }) {
|
|
455
|
-
const todos = await listTodos(runtime.manager, roleId);
|
|
456
|
-
return renderSpec(todoState(todos), runtime.functionId);
|
|
457
|
-
},
|
|
458
|
-
actions: {
|
|
459
|
-
addTodo: async ({ runtime, params, roleId }) => addTodo(runtime.manager, params, roleId),
|
|
460
|
-
toggleTodo: async ({ runtime, params, roleId }) => toggleTodo(runtime.manager, params, roleId),
|
|
461
|
-
clearCompleted: async ({ runtime, roleId }) => clearCompleted(runtime.manager, roleId),
|
|
462
|
-
},
|
|
463
|
-
});
|
|
464
|
-
|
|
465
461
|
export async function onRipplingEvent(
|
|
466
|
-
event:
|
|
462
|
+
event: SduiPageFunctionEvent<TodoPageFunctionParameters>,
|
|
467
463
|
context: FunctionContext,
|
|
468
|
-
): Promise<FunctionResponse
|
|
469
|
-
|
|
464
|
+
): Promise<FunctionResponse> {
|
|
465
|
+
const params = event.parameters;
|
|
466
|
+
const action = params.action;
|
|
467
|
+
const roleId = context.function.role_id;
|
|
468
|
+
if (!roleId) {
|
|
469
|
+
return badRequest('Role ID is required');
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
try {
|
|
473
|
+
const client = createClient(context);
|
|
474
|
+
|
|
475
|
+
if (action === 'init') {
|
|
476
|
+
const functionApiName = context.function.function_api_name;
|
|
477
|
+
const todos = await listTodos(client, roleId);
|
|
478
|
+
return ok({ spec: JSON.stringify(renderSpec(todoState(todos), functionApiName)) });
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (action === 'addTodo') {
|
|
482
|
+
return ok(await addTodo(client, params, roleId));
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (action === 'toggleTodo') {
|
|
486
|
+
return ok(await toggleTodo(client, params, roleId));
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (action === 'clearCompleted') {
|
|
490
|
+
return ok(await clearCompleted(client, roleId));
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return badRequest(`Unknown action: ${action}`);
|
|
494
|
+
} catch (error) {
|
|
495
|
+
return serverError(error);
|
|
496
|
+
}
|
|
470
497
|
}
|
package/examples/manifest/todo-app-without-object-list-view/todo-app-without-object-list-view.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Todo App Without ObjectListView — custom SDUI backed by
|
|
2
|
+
* Todo App Without ObjectListView — custom SDUI backed by Custom Object records.
|
|
3
3
|
*
|
|
4
4
|
* This example intentionally does not render ObjectListView. The SDUI page reads
|
|
5
|
-
* and writes `todo__c` records from the function, then renders its own
|
|
6
|
-
* list with TextInput, Button, Checkbox, and layout components.
|
|
5
|
+
* and writes `todo__c` records from the function, then renders its own
|
|
6
|
+
* todo list with TextInput, Button, Checkbox, and layout components.
|
|
7
7
|
*
|
|
8
8
|
* todo__c <- name, completed__c
|
|
9
9
|
*
|
|
@@ -12,34 +12,54 @@
|
|
|
12
12
|
* > examples/manifest/todo-app-without-object-list-view/manifest.json
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import * as fs from 'node:fs';
|
|
15
16
|
import * as path from 'node:path';
|
|
16
|
-
import { toCustomCategoryApiName } from '@rippling/rippling-sdk/core/platform/custom-objects';
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
App,
|
|
19
|
+
BooleanField,
|
|
20
|
+
Category,
|
|
21
|
+
CustomObject,
|
|
22
|
+
CustomObjectFieldSection,
|
|
23
|
+
CustomObjectPageLayout,
|
|
24
|
+
ManifestBuilder,
|
|
25
|
+
ManifestFunction,
|
|
26
|
+
SduiPage,
|
|
27
|
+
} from '@rippling/rippling-sdk/lib/manifest';
|
|
24
28
|
|
|
25
29
|
const manifest = new ManifestBuilder({
|
|
26
30
|
key: 'todo_app_without_object_list_view',
|
|
27
31
|
name: 'Todo App Without ObjectListView',
|
|
28
|
-
description: 'A todo app that renders custom SDUI and persists changes to
|
|
32
|
+
description: 'A todo app that renders custom SDUI and persists changes to Custom Object records',
|
|
29
33
|
});
|
|
30
34
|
|
|
31
35
|
const todoCategory = new Category(manifest, {
|
|
32
|
-
apiName:
|
|
36
|
+
apiName: 'custom_todo_app__c',
|
|
33
37
|
name: 'Todo App',
|
|
34
38
|
description: 'Custom todo app records',
|
|
35
39
|
});
|
|
36
40
|
|
|
37
|
-
const
|
|
38
|
-
|
|
41
|
+
const todoObj = new CustomObject(manifest, {
|
|
42
|
+
apiName: 'todo__c',
|
|
43
|
+
name: 'Todo',
|
|
44
|
+
pluralLabel: 'Todos',
|
|
39
45
|
category: todoCategory,
|
|
46
|
+
description: 'A todo item rendered by a custom SDUI page',
|
|
47
|
+
icon: { emoji: '✅' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const detailsSection = new CustomObjectFieldSection(todoObj, {
|
|
51
|
+
name: 'Details',
|
|
52
|
+
sectionId: 'sec_custom_todo_details',
|
|
40
53
|
});
|
|
41
54
|
|
|
42
|
-
|
|
55
|
+
const completedField = new BooleanField(todoObj, {
|
|
56
|
+
apiName: 'completed__c',
|
|
57
|
+
displayName: 'Completed',
|
|
58
|
+
description: 'Whether the todo item is complete',
|
|
59
|
+
section: detailsSection,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
new CustomObjectPageLayout(todoObj, {
|
|
43
63
|
apiName: 'default',
|
|
44
64
|
name: 'Todo',
|
|
45
65
|
layoutId: 'layout_custom_todo',
|
|
@@ -53,8 +73,8 @@ defineTypedPageLayout(todo, {
|
|
|
53
73
|
{
|
|
54
74
|
name: 'Details',
|
|
55
75
|
type: 'fields_section',
|
|
56
|
-
section:
|
|
57
|
-
fields: [{ field: 'name', editable: true },
|
|
76
|
+
section: detailsSection,
|
|
77
|
+
fields: [{ field: 'name', editable: true }, completedField],
|
|
58
78
|
},
|
|
59
79
|
],
|
|
60
80
|
},
|
|
@@ -65,22 +85,25 @@ defineTypedPageLayout(todo, {
|
|
|
65
85
|
visibilityConditions: {},
|
|
66
86
|
});
|
|
67
87
|
|
|
68
|
-
const
|
|
88
|
+
const todoPageFn = new ManifestFunction(manifest, {
|
|
69
89
|
apiName: 'custom_todo_page_fn',
|
|
70
90
|
name: 'renderTodoPage',
|
|
71
|
-
description: 'Custom SDUI todo page backed by
|
|
72
|
-
|
|
73
|
-
codeFilename: 'todo-page.ts',
|
|
91
|
+
description: 'Custom SDUI todo page backed by Custom Object record APIs',
|
|
92
|
+
code: fs.readFileSync(path.join(__dirname, 'functions', 'todo-page.ts'), 'utf-8'),
|
|
74
93
|
dependencies: { '@rippling/rippling-sdk': '^0.2.0-alpha.65', '@rippling/pebble-sdui-web': '^0.9.2' },
|
|
75
94
|
isAsync: false,
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const todoPage = new SduiPage(manifest, {
|
|
98
|
+
sduiPageId: 'custom_todo_page',
|
|
99
|
+
name: 'Todos',
|
|
100
|
+
function: todoPageFn,
|
|
78
101
|
});
|
|
79
102
|
|
|
80
103
|
new App(manifest, {
|
|
81
104
|
apiName: 'todo_app_without_object_list_view',
|
|
82
105
|
name: 'Todo App Without ObjectListView',
|
|
83
|
-
description: 'Todo app with a fully custom SDUI page and
|
|
106
|
+
description: 'Todo app with a fully custom SDUI page and Custom Object persistence',
|
|
84
107
|
appType: 'custom',
|
|
85
108
|
pages: [todoPage],
|
|
86
109
|
});
|