@rippling/rippling-sdk 0.2.0-alpha.82 → 0.2.0-alpha.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.mts +4 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +4 -4
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/core/platform/custom-objects/category.d.mts +125 -0
- package/core/platform/custom-objects/category.d.mts.map +1 -0
- package/core/platform/custom-objects/category.d.ts +125 -0
- package/core/platform/custom-objects/category.d.ts.map +1 -0
- package/core/platform/custom-objects/category.js +188 -0
- package/core/platform/custom-objects/category.js.map +1 -0
- package/core/platform/custom-objects/category.mjs +178 -0
- package/core/platform/custom-objects/category.mjs.map +1 -0
- package/core/platform/custom-objects/definition.d.mts +147 -0
- package/core/platform/custom-objects/definition.d.mts.map +1 -0
- package/core/platform/custom-objects/definition.d.ts +147 -0
- package/core/platform/custom-objects/definition.d.ts.map +1 -0
- package/core/platform/custom-objects/definition.js +200 -0
- package/core/platform/custom-objects/definition.js.map +1 -0
- package/core/platform/custom-objects/definition.mjs +190 -0
- package/core/platform/custom-objects/definition.mjs.map +1 -0
- package/core/platform/custom-objects/fields.d.mts +302 -0
- package/core/platform/custom-objects/fields.d.mts.map +1 -0
- package/core/platform/custom-objects/fields.d.ts +302 -0
- package/core/platform/custom-objects/fields.d.ts.map +1 -0
- package/core/platform/custom-objects/fields.js +369 -0
- package/core/platform/custom-objects/fields.js.map +1 -0
- package/core/platform/custom-objects/fields.mjs +347 -0
- package/core/platform/custom-objects/fields.mjs.map +1 -0
- package/core/platform/custom-objects/function-runtime.d.mts +42 -0
- package/core/platform/custom-objects/function-runtime.d.mts.map +1 -0
- package/core/platform/custom-objects/function-runtime.d.ts +42 -0
- package/core/platform/custom-objects/function-runtime.d.ts.map +1 -0
- package/core/platform/custom-objects/function-runtime.js +38 -0
- package/core/platform/custom-objects/function-runtime.js.map +1 -0
- package/core/platform/custom-objects/function-runtime.mjs +35 -0
- package/core/platform/custom-objects/function-runtime.mjs.map +1 -0
- package/core/platform/custom-objects/lifecycle.d.mts +83 -0
- package/core/platform/custom-objects/lifecycle.d.mts.map +1 -0
- package/core/platform/custom-objects/lifecycle.d.ts +83 -0
- package/core/platform/custom-objects/lifecycle.d.ts.map +1 -0
- package/core/platform/custom-objects/lifecycle.js +372 -0
- package/core/platform/custom-objects/lifecycle.js.map +1 -0
- package/core/platform/custom-objects/lifecycle.mjs +367 -0
- package/core/platform/custom-objects/lifecycle.mjs.map +1 -0
- package/core/platform/custom-objects/manager.d.mts +354 -0
- package/core/platform/custom-objects/manager.d.mts.map +1 -0
- package/core/platform/custom-objects/manager.d.ts +354 -0
- package/core/platform/custom-objects/manager.d.ts.map +1 -0
- package/core/platform/custom-objects/manager.js +646 -0
- package/core/platform/custom-objects/manager.js.map +1 -0
- package/core/platform/custom-objects/manager.mjs +637 -0
- package/core/platform/custom-objects/manager.mjs.map +1 -0
- package/core/platform/custom-objects/provisioning.d.mts +138 -0
- package/core/platform/custom-objects/provisioning.d.mts.map +1 -0
- package/core/platform/custom-objects/provisioning.d.ts +138 -0
- package/core/platform/custom-objects/provisioning.d.ts.map +1 -0
- package/core/platform/custom-objects/provisioning.js +455 -0
- package/core/platform/custom-objects/provisioning.js.map +1 -0
- package/core/platform/custom-objects/provisioning.mjs +447 -0
- package/core/platform/custom-objects/provisioning.mjs.map +1 -0
- package/core/platform/custom-objects/rql.d.mts +122 -0
- package/core/platform/custom-objects/rql.d.mts.map +1 -0
- package/core/platform/custom-objects/rql.d.ts +122 -0
- package/core/platform/custom-objects/rql.d.ts.map +1 -0
- package/core/platform/custom-objects/rql.js +225 -0
- package/core/platform/custom-objects/rql.js.map +1 -0
- package/core/platform/custom-objects/rql.mjs +222 -0
- package/core/platform/custom-objects/rql.mjs.map +1 -0
- package/core/platform/custom-objects/schema-manager.d.mts +203 -0
- package/core/platform/custom-objects/schema-manager.d.mts.map +1 -0
- package/core/platform/custom-objects/schema-manager.d.ts +203 -0
- package/core/platform/custom-objects/schema-manager.d.ts.map +1 -0
- package/core/platform/custom-objects/schema-manager.js +256 -0
- package/core/platform/custom-objects/schema-manager.js.map +1 -0
- package/core/platform/custom-objects/schema-manager.mjs +249 -0
- package/core/platform/custom-objects/schema-manager.mjs.map +1 -0
- package/core/platform/custom-objects/typed-rql.d.mts +157 -0
- package/core/platform/custom-objects/typed-rql.d.mts.map +1 -0
- package/core/platform/custom-objects/typed-rql.d.ts +157 -0
- package/core/platform/custom-objects/typed-rql.d.ts.map +1 -0
- package/core/platform/custom-objects/typed-rql.js +583 -0
- package/core/platform/custom-objects/typed-rql.js.map +1 -0
- package/core/platform/custom-objects/typed-rql.mjs +580 -0
- package/core/platform/custom-objects/typed-rql.mjs.map +1 -0
- package/core/platform/custom-objects/types.d.mts +549 -0
- package/core/platform/custom-objects/types.d.mts.map +1 -0
- package/core/platform/custom-objects/types.d.ts +549 -0
- package/core/platform/custom-objects/types.d.ts.map +1 -0
- package/core/platform/custom-objects/types.js +20 -0
- package/core/platform/custom-objects/types.js.map +1 -0
- package/core/platform/custom-objects/types.mjs +17 -0
- package/core/platform/custom-objects/types.mjs.map +1 -0
- package/core/platform/custom-objects/validation.d.mts +97 -0
- package/core/platform/custom-objects/validation.d.mts.map +1 -0
- package/core/platform/custom-objects/validation.d.ts +97 -0
- package/core/platform/custom-objects/validation.d.ts.map +1 -0
- package/core/platform/custom-objects/validation.js +477 -0
- package/core/platform/custom-objects/validation.js.map +1 -0
- package/core/platform/custom-objects/validation.mjs +465 -0
- package/core/platform/custom-objects/validation.mjs.map +1 -0
- package/core/platform/custom-objects.d.mts +67 -0
- package/core/platform/custom-objects.d.mts.map +1 -0
- package/core/platform/custom-objects.d.ts +67 -0
- package/core/platform/custom-objects.d.ts.map +1 -0
- package/core/platform/custom-objects.js +118 -0
- package/core/platform/custom-objects.js.map +1 -0
- package/core/platform/custom-objects.mjs +45 -0
- package/core/platform/custom-objects.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/action.d.mts +58 -0
- package/core/platform/manifest/custom-objects/action.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/action.d.ts +58 -0
- package/core/platform/manifest/custom-objects/action.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/action.js +44 -0
- package/core/platform/manifest/custom-objects/action.js.map +1 -0
- package/core/platform/manifest/custom-objects/action.mjs +40 -0
- package/core/platform/manifest/custom-objects/action.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/conditions.d.mts +240 -0
- package/core/platform/manifest/custom-objects/conditions.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/conditions.d.ts +240 -0
- package/core/platform/manifest/custom-objects/conditions.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/conditions.js +326 -0
- package/core/platform/manifest/custom-objects/conditions.js.map +1 -0
- package/core/platform/manifest/custom-objects/conditions.mjs +321 -0
- package/core/platform/manifest/custom-objects/conditions.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/existing.d.mts +87 -0
- package/core/platform/manifest/custom-objects/existing.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/existing.d.ts +87 -0
- package/core/platform/manifest/custom-objects/existing.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/existing.js +113 -0
- package/core/platform/manifest/custom-objects/existing.js.map +1 -0
- package/core/platform/manifest/custom-objects/existing.mjs +109 -0
- package/core/platform/manifest/custom-objects/existing.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/field-resolution.d.mts +48 -0
- package/core/platform/manifest/custom-objects/field-resolution.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/field-resolution.d.ts +48 -0
- package/core/platform/manifest/custom-objects/field-resolution.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/field-resolution.js +61 -0
- package/core/platform/manifest/custom-objects/field-resolution.js.map +1 -0
- package/core/platform/manifest/custom-objects/field-resolution.mjs +58 -0
- package/core/platform/manifest/custom-objects/field-resolution.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/function-file.d.mts +87 -0
- package/core/platform/manifest/custom-objects/function-file.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/function-file.d.ts +87 -0
- package/core/platform/manifest/custom-objects/function-file.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/function-file.js +76 -0
- package/core/platform/manifest/custom-objects/function-file.js.map +1 -0
- package/core/platform/manifest/custom-objects/function-file.mjs +69 -0
- package/core/platform/manifest/custom-objects/function-file.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/list-view.d.mts +65 -0
- package/core/platform/manifest/custom-objects/list-view.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/list-view.d.ts +65 -0
- package/core/platform/manifest/custom-objects/list-view.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/list-view.js +33 -0
- package/core/platform/manifest/custom-objects/list-view.js.map +1 -0
- package/core/platform/manifest/custom-objects/list-view.mjs +30 -0
- package/core/platform/manifest/custom-objects/list-view.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/object-list-page.d.mts +43 -0
- package/core/platform/manifest/custom-objects/object-list-page.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/object-list-page.d.ts +43 -0
- package/core/platform/manifest/custom-objects/object-list-page.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/object-list-page.js +54 -0
- package/core/platform/manifest/custom-objects/object-list-page.js.map +1 -0
- package/core/platform/manifest/custom-objects/object-list-page.mjs +50 -0
- package/core/platform/manifest/custom-objects/object-list-page.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/page-layout.d.mts +142 -0
- package/core/platform/manifest/custom-objects/page-layout.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/page-layout.d.ts +142 -0
- package/core/platform/manifest/custom-objects/page-layout.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/page-layout.js +184 -0
- package/core/platform/manifest/custom-objects/page-layout.js.map +1 -0
- package/core/platform/manifest/custom-objects/page-layout.mjs +180 -0
- package/core/platform/manifest/custom-objects/page-layout.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/register.d.mts +87 -0
- package/core/platform/manifest/custom-objects/register.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/register.d.ts +87 -0
- package/core/platform/manifest/custom-objects/register.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/register.js +395 -0
- package/core/platform/manifest/custom-objects/register.js.map +1 -0
- package/core/platform/manifest/custom-objects/register.mjs +391 -0
- package/core/platform/manifest/custom-objects/register.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/rule.d.mts +113 -0
- package/core/platform/manifest/custom-objects/rule.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/rule.d.ts +113 -0
- package/core/platform/manifest/custom-objects/rule.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/rule.js +49 -0
- package/core/platform/manifest/custom-objects/rule.js.map +1 -0
- package/core/platform/manifest/custom-objects/rule.mjs +45 -0
- package/core/platform/manifest/custom-objects/rule.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/sdui-page.d.mts +214 -0
- package/core/platform/manifest/custom-objects/sdui-page.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/sdui-page.d.ts +214 -0
- package/core/platform/manifest/custom-objects/sdui-page.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/sdui-page.js +194 -0
- package/core/platform/manifest/custom-objects/sdui-page.js.map +1 -0
- package/core/platform/manifest/custom-objects/sdui-page.mjs +182 -0
- package/core/platform/manifest/custom-objects/sdui-page.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/typed-condition.d.mts +28 -0
- package/core/platform/manifest/custom-objects/typed-condition.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/typed-condition.d.ts +28 -0
- package/core/platform/manifest/custom-objects/typed-condition.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/typed-condition.js +434 -0
- package/core/platform/manifest/custom-objects/typed-condition.js.map +1 -0
- package/core/platform/manifest/custom-objects/typed-condition.mjs +431 -0
- package/core/platform/manifest/custom-objects/typed-condition.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/types.d.mts +29 -0
- package/core/platform/manifest/custom-objects/types.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/types.d.ts +29 -0
- package/core/platform/manifest/custom-objects/types.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/types.js +3 -0
- package/core/platform/manifest/custom-objects/types.js.map +1 -0
- package/core/platform/manifest/custom-objects/types.mjs +2 -0
- package/core/platform/manifest/custom-objects/types.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/validation.d.mts +44 -0
- package/core/platform/manifest/custom-objects/validation.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/validation.d.ts +44 -0
- package/core/platform/manifest/custom-objects/validation.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/validation.js +30 -0
- package/core/platform/manifest/custom-objects/validation.js.map +1 -0
- package/core/platform/manifest/custom-objects/validation.mjs +27 -0
- package/core/platform/manifest/custom-objects/validation.mjs.map +1 -0
- package/core/platform/manifest/custom-objects/workflow.d.mts +47 -0
- package/core/platform/manifest/custom-objects/workflow.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects/workflow.d.ts +47 -0
- package/core/platform/manifest/custom-objects/workflow.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects/workflow.js +38 -0
- package/core/platform/manifest/custom-objects/workflow.js.map +1 -0
- package/core/platform/manifest/custom-objects/workflow.mjs +34 -0
- package/core/platform/manifest/custom-objects/workflow.mjs.map +1 -0
- package/core/platform/manifest/custom-objects.d.mts +85 -0
- package/core/platform/manifest/custom-objects.d.mts.map +1 -0
- package/core/platform/manifest/custom-objects.d.ts +85 -0
- package/core/platform/manifest/custom-objects.d.ts.map +1 -0
- package/core/platform/manifest/custom-objects.js +84 -0
- package/core/platform/manifest/custom-objects.js.map +1 -0
- package/core/platform/manifest/custom-objects.mjs +55 -0
- package/core/platform/manifest/custom-objects.mjs.map +1 -0
- package/examples/manifest/custom-object-creation-workflow/custom-object-creation-workflow.ts +26 -44
- package/examples/manifest/custom-object-creation-workflow/functions/intake-request-created.ts +20 -0
- package/examples/manifest/custom-object-creation-workflow/schema.ts +29 -0
- package/examples/manifest/dental-practice-management/dental-practice-management.ts +142 -470
- package/examples/manifest/dental-practice-management/functions/chair-schedule.ts +13 -23
- package/examples/manifest/dental-practice-management/functions/complete-visit.ts +32 -55
- package/examples/manifest/dental-practice-management/functions/operatory-list.ts +13 -23
- package/examples/manifest/dental-practice-management/functions/patient-list.ts +13 -23
- package/examples/manifest/dental-practice-management/functions/treatment-plan-list.ts +13 -23
- package/examples/manifest/dental-practice-management/schema.ts +298 -0
- package/examples/manifest/existing-manifest-mutations/existing-manifest-mutations.ts +68 -23
- package/examples/manifest/field-service-dispatch/field-service-dispatch.ts +102 -375
- package/examples/manifest/field-service-dispatch/schema.ts +248 -0
- package/examples/manifest/grant-program-management/grant-program-management.ts +125 -419
- package/examples/manifest/grant-program-management/schema.ts +269 -0
- package/examples/manifest/gym-membership-management/functions/check-in-desk.ts +13 -23
- package/examples/manifest/gym-membership-management/functions/member-list.ts +13 -23
- package/examples/manifest/gym-membership-management/functions/today-schedule.ts +13 -23
- package/examples/manifest/gym-membership-management/functions/trainer-list.ts +13 -23
- package/examples/manifest/gym-membership-management/gym-membership-management.ts +92 -442
- package/examples/manifest/gym-membership-management/schema.ts +266 -0
- package/examples/manifest/procurement-approval-hub/functions/route-purchase-request.ts +20 -0
- package/examples/manifest/procurement-approval-hub/procurement-approval-hub.ts +122 -408
- package/examples/manifest/procurement-approval-hub/schema.ts +256 -0
- package/examples/manifest/simple-todo-app/functions/mark-done.ts +16 -12
- package/examples/manifest/simple-todo-app/functions/todo-list.ts +13 -23
- package/examples/manifest/simple-todo-app/schema.ts +60 -0
- package/examples/manifest/simple-todo-app/simple-todo-app.ts +40 -109
- package/examples/manifest/todo-app-without-object-list-view/functions/todo-page.ts +166 -193
- package/examples/manifest/todo-app-without-object-list-view/schema.ts +28 -0
- package/examples/manifest/todo-app-without-object-list-view/todo-app-without-object-list-view.ts +24 -47
- package/package.json +7 -13
- package/resources/custom-objects/custom-objects.d.mts +7 -0
- package/resources/custom-objects/custom-objects.d.mts.map +1 -1
- package/resources/custom-objects/custom-objects.d.ts +7 -0
- 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 +170 -15
- package/resources/custom-objects/fields.d.mts.map +1 -1
- package/resources/custom-objects/fields.d.ts +170 -15
- package/resources/custom-objects/fields.d.ts.map +1 -1
- package/resources/index.d.mts +2 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/leave-program-evaluations.d.mts +510 -3
- package/resources/leave-program-evaluations.d.mts.map +1 -1
- package/resources/leave-program-evaluations.d.ts +510 -3
- package/resources/leave-program-evaluations.d.ts.map +1 -1
- package/resources/levels.d.mts +64 -2
- package/resources/levels.d.mts.map +1 -1
- package/resources/levels.d.ts +64 -2
- package/resources/levels.d.ts.map +1 -1
- package/resources/levels.js +22 -0
- package/resources/levels.js.map +1 -1
- package/resources/levels.mjs +22 -0
- package/resources/levels.mjs.map +1 -1
- package/resources/tracks.d.mts +45 -1
- package/resources/tracks.d.mts.map +1 -1
- package/resources/tracks.d.ts +45 -1
- package/resources/tracks.d.ts.map +1 -1
- package/resources/tracks.js +22 -0
- package/resources/tracks.js.map +1 -1
- package/resources/tracks.mjs +22 -0
- package/resources/tracks.mjs.map +1 -1
- package/src/client.ts +8 -0
- package/src/core/platform/README.md +20 -0
- package/src/core/platform/custom-objects/category.ts +294 -0
- package/src/core/platform/custom-objects/definition.ts +373 -0
- package/src/core/platform/custom-objects/fields.ts +653 -0
- package/src/core/platform/custom-objects/function-runtime.ts +76 -0
- package/src/core/platform/custom-objects/lifecycle.ts +557 -0
- package/src/core/platform/custom-objects/manager.ts +959 -0
- package/src/core/platform/custom-objects/provisioning.ts +672 -0
- package/src/core/platform/custom-objects/rql.ts +375 -0
- package/src/core/platform/custom-objects/schema-manager.ts +351 -0
- package/src/core/platform/custom-objects/typed-rql.ts +1273 -0
- package/src/core/platform/custom-objects/types.ts +753 -0
- package/src/core/platform/custom-objects/validation.ts +573 -0
- package/src/core/platform/custom-objects.ts +269 -0
- package/src/core/platform/manifest/README.md +26 -0
- package/src/core/platform/manifest/custom-objects/action.ts +87 -0
- package/src/core/platform/manifest/custom-objects/conditions.ts +762 -0
- package/src/core/platform/manifest/custom-objects/existing.ts +221 -0
- package/src/core/platform/manifest/custom-objects/field-resolution.ts +116 -0
- package/src/core/platform/manifest/custom-objects/function-file.ts +149 -0
- package/src/core/platform/manifest/custom-objects/list-view.ts +95 -0
- package/src/core/platform/manifest/custom-objects/object-list-page.ts +87 -0
- package/src/core/platform/manifest/custom-objects/page-layout.ts +380 -0
- package/src/core/platform/manifest/custom-objects/register.ts +555 -0
- package/src/core/platform/manifest/custom-objects/rule.ts +192 -0
- package/src/core/platform/manifest/custom-objects/sdui-page.ts +515 -0
- package/src/core/platform/manifest/custom-objects/typed-condition.ts +617 -0
- package/src/core/platform/manifest/custom-objects/types.ts +92 -0
- package/src/core/platform/manifest/custom-objects/validation.ts +70 -0
- package/src/core/platform/manifest/custom-objects/workflow.ts +71 -0
- package/src/core/platform/manifest/custom-objects.ts +203 -0
- package/src/pebble-sdui-web-custom-apps-shim.d.ts +3 -0
- package/src/resources/custom-objects/custom-objects.ts +8 -0
- package/src/resources/custom-objects/fields.ts +239 -14
- package/src/resources/index.ts +4 -0
- package/src/resources/leave-program-evaluations.ts +610 -3
- package/src/resources/levels.ts +93 -1
- package/src/resources/tracks.ts +70 -0
- 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
|
@@ -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 `functionId`,
|
|
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,23 +29,31 @@ import {
|
|
|
29
29
|
TextInput,
|
|
30
30
|
VStack,
|
|
31
31
|
render,
|
|
32
|
-
setState,
|
|
33
|
-
triggerFunction,
|
|
34
32
|
} from '@rippling/pebble-sdui-web/catalogs/custom-apps';
|
|
35
|
-
import
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
import { FunctionContext, FunctionResponse, SduiPageFunctionEvent } from '@rippling/rippling-sdk';
|
|
34
|
+
import {
|
|
35
|
+
createCustomObjectFunctionRuntime,
|
|
36
|
+
createRqlHelpers,
|
|
37
|
+
type RecordShape,
|
|
38
|
+
type TypedCustomObjectRecordManager,
|
|
39
|
+
} from '@rippling/rippling-sdk/core/platform/custom-objects';
|
|
40
|
+
import {
|
|
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);
|
|
43
51
|
type TodoPageAction = 'init' | 'addTodo' | 'toggleTodo' | 'clearCompleted';
|
|
44
|
-
type TodoPageFunctionParameters =
|
|
45
|
-
action:
|
|
46
|
-
text?: string
|
|
47
|
-
todoId?: string
|
|
48
|
-
};
|
|
52
|
+
type TodoPageFunctionParameters =
|
|
53
|
+
| { action: 'init' }
|
|
54
|
+
| { action: 'addTodo'; text?: string }
|
|
55
|
+
| { action: 'toggleTodo'; todoId?: string }
|
|
56
|
+
| { action: 'clearCompleted' };
|
|
49
57
|
|
|
50
58
|
type Todo = {
|
|
51
59
|
id: string;
|
|
@@ -53,6 +61,8 @@ type Todo = {
|
|
|
53
61
|
completed: boolean;
|
|
54
62
|
};
|
|
55
63
|
|
|
64
|
+
type TodoRecord = RecordShape<typeof todoDefinition>;
|
|
65
|
+
|
|
56
66
|
type TodoListState = {
|
|
57
67
|
todos: Todo[];
|
|
58
68
|
isEmpty: boolean;
|
|
@@ -67,27 +77,43 @@ type TodoAppState = {
|
|
|
67
77
|
|
|
68
78
|
type TodoSpec = SpecContext<TodoAppState>;
|
|
69
79
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
const todoStatePath = resolveTypedSduiStatePath<TodoAppState>();
|
|
81
|
+
const todoStatePaths = {
|
|
82
|
+
newTodoText: todoStatePath('/newTodoText'),
|
|
83
|
+
todoList: todoStatePath('/todoList'),
|
|
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);
|
|
74
97
|
}
|
|
75
98
|
|
|
76
|
-
function toTodo(record:
|
|
99
|
+
function toTodo(record: TodoRecord): Todo {
|
|
77
100
|
return {
|
|
78
101
|
id: record.id,
|
|
79
102
|
text: record.name,
|
|
80
|
-
completed: record
|
|
103
|
+
completed: record.completed === true,
|
|
81
104
|
};
|
|
82
105
|
}
|
|
83
106
|
|
|
84
|
-
async function listTodos(
|
|
85
|
-
|
|
107
|
+
async function listTodos(
|
|
108
|
+
manager: TypedCustomObjectRecordManager<typeof todoDefinition>,
|
|
109
|
+
roleId: string,
|
|
110
|
+
): Promise<Todo[]> {
|
|
111
|
+
const response = await manager.query({
|
|
86
112
|
limit: 100,
|
|
87
|
-
query:
|
|
113
|
+
query: todoRql.render(todoRql.eq(todoRql.fields.created_by, { id: roleId, apiName: 'Employee' })),
|
|
88
114
|
});
|
|
89
115
|
|
|
90
|
-
return
|
|
116
|
+
return response.results.map(toTodo);
|
|
91
117
|
}
|
|
92
118
|
|
|
93
119
|
function todoListState(todos: Todo[]): TodoListState {
|
|
@@ -106,49 +132,32 @@ function todoState(todos: Todo[]): TodoAppState {
|
|
|
106
132
|
};
|
|
107
133
|
}
|
|
108
134
|
|
|
109
|
-
function
|
|
110
|
-
return
|
|
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
|
-
});
|
|
135
|
+
function todoTextParam(params: TypedSduiPageActionParams<TodoPageFunctionParameters, 'addTodo'>): string {
|
|
136
|
+
return typeof params.text === 'string' ? params.text.trim() : '';
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
return typeof value === 'string' ? value.trim() : '';
|
|
139
|
+
function todoIdParam(params: TypedSduiPageActionParams<TodoPageFunctionParameters, 'toggleTodo'>): string {
|
|
140
|
+
return typeof params.todoId === 'string' ? params.todoId.trim() : '';
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
function mutationActions<TInputs extends { action: Exclude<TodoPageAction, 'init'> }>(
|
|
144
|
+
functionId: string,
|
|
145
|
+
inputs: TInputs,
|
|
146
|
+
errorMessage: string,
|
|
147
|
+
onSuccessState?: ReturnType<typeof defineTypedSduiStateAssignments<TodoAppState>>,
|
|
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 } : {}),
|
|
148
157
|
});
|
|
149
158
|
}
|
|
150
159
|
|
|
151
|
-
function buildAddTodoSection(spec: TodoSpec,
|
|
160
|
+
function buildAddTodoSection(spec: TodoSpec, functionId: string) {
|
|
152
161
|
return VStack({
|
|
153
162
|
id: 'addTodoSection',
|
|
154
163
|
props: {},
|
|
@@ -164,8 +173,8 @@ function buildAddTodoSection(spec: TodoSpec, functionApiName: string) {
|
|
|
164
173
|
props: {
|
|
165
174
|
name: 'newTodo',
|
|
166
175
|
placeholder: 'Enter a new todo item',
|
|
167
|
-
value: spec.$bindState(
|
|
168
|
-
isDisabled: spec.$state(
|
|
176
|
+
value: spec.$bindState(todoStatePaths.newTodoText),
|
|
177
|
+
isDisabled: spec.$state(todoStatePaths.isMutating),
|
|
169
178
|
},
|
|
170
179
|
}),
|
|
171
180
|
],
|
|
@@ -177,37 +186,34 @@ function buildAddTodoSection(spec: TodoSpec, functionApiName: string) {
|
|
|
177
186
|
appearance: 'PRIMARY',
|
|
178
187
|
isFluid: true,
|
|
179
188
|
isDisabled: spec.$cond(
|
|
180
|
-
or_(
|
|
189
|
+
or_(
|
|
190
|
+
equals(spec.$state(todoStatePaths.newTodoText), ''),
|
|
191
|
+
equals(spec.$state(todoStatePaths.isMutating), true),
|
|
192
|
+
),
|
|
181
193
|
true,
|
|
182
194
|
false,
|
|
183
195
|
),
|
|
184
196
|
},
|
|
185
197
|
on: {
|
|
186
|
-
press:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
{
|
|
198
|
-
onSuccess: { set: { '/newTodoText': '', '/errorMessage': '', '/isMutating': false } },
|
|
199
|
-
onError: { set: { '/errorMessage': 'Could not add todo. Try again.', '/isMutating': false } },
|
|
200
|
-
},
|
|
201
|
-
),
|
|
202
|
-
],
|
|
198
|
+
press: mutationActions(
|
|
199
|
+
functionId,
|
|
200
|
+
{
|
|
201
|
+
action: 'addTodo',
|
|
202
|
+
text: spec.$state(todoStatePaths.newTodoText),
|
|
203
|
+
},
|
|
204
|
+
'Could not add todo. Try again.',
|
|
205
|
+
defineTypedSduiStateAssignments<TodoAppState>({
|
|
206
|
+
[todoStatePaths.newTodoText]: '',
|
|
207
|
+
}),
|
|
208
|
+
),
|
|
203
209
|
},
|
|
204
210
|
}),
|
|
205
211
|
],
|
|
206
212
|
});
|
|
207
213
|
}
|
|
208
214
|
|
|
209
|
-
function buildTodoItems(spec: TodoSpec,
|
|
210
|
-
const [todoRepeat, todo] = spec.repeat(
|
|
215
|
+
function buildTodoItems(spec: TodoSpec, functionId: string) {
|
|
216
|
+
const [todoRepeat, todo] = spec.repeat(todoStatePaths.todoListTodos, 'id');
|
|
211
217
|
|
|
212
218
|
return VStack({
|
|
213
219
|
id: 'todoItems',
|
|
@@ -231,31 +237,17 @@ function buildTodoItems(spec: TodoSpec, functionApiName: string) {
|
|
|
231
237
|
props: {
|
|
232
238
|
name: 'completed',
|
|
233
239
|
value: todo.$bind('completed'),
|
|
234
|
-
isDisabled: spec.$state(
|
|
240
|
+
isDisabled: spec.$state(todoStatePaths.isMutating),
|
|
235
241
|
},
|
|
236
242
|
on: {
|
|
237
|
-
change:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
],
|
|
243
|
+
change: mutationActions(
|
|
244
|
+
functionId,
|
|
245
|
+
{
|
|
246
|
+
action: 'toggleTodo',
|
|
247
|
+
todoId: todo.$('id'),
|
|
248
|
+
},
|
|
249
|
+
'Could not update todo. Refresh and try again.',
|
|
250
|
+
),
|
|
259
251
|
},
|
|
260
252
|
}),
|
|
261
253
|
Text({
|
|
@@ -272,7 +264,7 @@ function buildTodoItems(spec: TodoSpec, functionApiName: string) {
|
|
|
272
264
|
});
|
|
273
265
|
}
|
|
274
266
|
|
|
275
|
-
function buildTodoList(spec: TodoSpec,
|
|
267
|
+
function buildTodoList(spec: TodoSpec, functionId: string) {
|
|
276
268
|
return VStack({
|
|
277
269
|
id: 'todoList',
|
|
278
270
|
props: {
|
|
@@ -301,46 +293,35 @@ function buildTodoList(spec: TodoSpec, functionApiName: string) {
|
|
|
301
293
|
appearance: 'OUTLINE',
|
|
302
294
|
size: 'S',
|
|
303
295
|
isDisabled: spec.$cond(
|
|
304
|
-
or_(
|
|
296
|
+
or_(
|
|
297
|
+
equals(spec.$state(todoStatePaths.isMutating), true),
|
|
298
|
+
equals(spec.$state(todoStatePaths.todoListIsEmpty), true),
|
|
299
|
+
),
|
|
305
300
|
true,
|
|
306
301
|
false,
|
|
307
302
|
),
|
|
308
303
|
},
|
|
309
304
|
on: {
|
|
310
|
-
press:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
],
|
|
305
|
+
press: mutationActions(
|
|
306
|
+
functionId,
|
|
307
|
+
{
|
|
308
|
+
action: 'clearCompleted',
|
|
309
|
+
},
|
|
310
|
+
'Could not clear completed todos. Try again.',
|
|
311
|
+
),
|
|
331
312
|
},
|
|
332
313
|
}),
|
|
333
314
|
],
|
|
334
315
|
}),
|
|
335
316
|
Text({
|
|
336
317
|
id: 'emptyTodos',
|
|
337
|
-
visible: equals(spec.$state(
|
|
318
|
+
visible: equals(spec.$state(todoStatePaths.todoListIsEmpty), true),
|
|
338
319
|
props: {
|
|
339
320
|
text: 'No todos yet.',
|
|
340
321
|
color: 'colorOnSurfaceVariant',
|
|
341
322
|
},
|
|
342
323
|
}),
|
|
343
|
-
buildTodoItems(spec,
|
|
324
|
+
buildTodoItems(spec, functionId),
|
|
344
325
|
],
|
|
345
326
|
});
|
|
346
327
|
}
|
|
@@ -348,9 +329,9 @@ function buildTodoList(spec: TodoSpec, functionApiName: string) {
|
|
|
348
329
|
function buildError(spec: TodoSpec) {
|
|
349
330
|
return Text({
|
|
350
331
|
id: 'todoError',
|
|
351
|
-
visible: neq(spec.$state(
|
|
332
|
+
visible: neq(spec.$state(todoStatePaths.errorMessage), ''),
|
|
352
333
|
props: {
|
|
353
|
-
text: spec.$state(
|
|
334
|
+
text: spec.$state(todoStatePaths.errorMessage),
|
|
354
335
|
color: 'colorError',
|
|
355
336
|
},
|
|
356
337
|
});
|
|
@@ -360,7 +341,7 @@ function buildLoading(spec: TodoSpec) {
|
|
|
360
341
|
return Text({
|
|
361
342
|
id: 'todoLoading',
|
|
362
343
|
// Keep disabled controls explainable while a triggerFunction call is in flight.
|
|
363
|
-
visible: equals(spec.$state(
|
|
344
|
+
visible: equals(spec.$state(todoStatePaths.isMutating), true),
|
|
364
345
|
props: {
|
|
365
346
|
text: 'Updating todos...',
|
|
366
347
|
color: 'colorOnSurfaceVariant',
|
|
@@ -368,7 +349,7 @@ function buildLoading(spec: TodoSpec) {
|
|
|
368
349
|
});
|
|
369
350
|
}
|
|
370
351
|
|
|
371
|
-
function buildTodoCard(spec: TodoSpec,
|
|
352
|
+
function buildTodoCard(spec: TodoSpec, functionId: string) {
|
|
372
353
|
return Card({
|
|
373
354
|
id: 'todoCard',
|
|
374
355
|
props: {},
|
|
@@ -380,17 +361,17 @@ function buildTodoCard(spec: TodoSpec, functionApiName: string) {
|
|
|
380
361
|
padding: 'space400',
|
|
381
362
|
},
|
|
382
363
|
children: [
|
|
383
|
-
buildAddTodoSection(spec,
|
|
364
|
+
buildAddTodoSection(spec, functionId),
|
|
384
365
|
buildError(spec),
|
|
385
366
|
buildLoading(spec),
|
|
386
|
-
buildTodoList(spec,
|
|
367
|
+
buildTodoList(spec, functionId),
|
|
387
368
|
],
|
|
388
369
|
}),
|
|
389
370
|
],
|
|
390
371
|
});
|
|
391
372
|
}
|
|
392
373
|
|
|
393
|
-
function renderSpec(state: TodoAppState,
|
|
374
|
+
function renderSpec(state: TodoAppState, functionId: string) {
|
|
394
375
|
const spec = createSpec<TodoAppState>({ state });
|
|
395
376
|
const root = PageContent({
|
|
396
377
|
id: 'todoApp',
|
|
@@ -398,100 +379,92 @@ function renderSpec(state: TodoAppState, functionApiName: string) {
|
|
|
398
379
|
size: '776',
|
|
399
380
|
alignment: 'CENTER',
|
|
400
381
|
},
|
|
401
|
-
children: [buildTodoCard(spec,
|
|
382
|
+
children: [buildTodoCard(spec, functionId)],
|
|
402
383
|
});
|
|
403
384
|
|
|
404
385
|
return render({ root, state });
|
|
405
386
|
}
|
|
406
387
|
|
|
407
388
|
async function addTodo(
|
|
408
|
-
|
|
409
|
-
params: TodoPageFunctionParameters,
|
|
389
|
+
manager: TypedCustomObjectRecordManager<typeof todoDefinition>,
|
|
390
|
+
params: TypedSduiPageActionParams<TodoPageFunctionParameters, 'addTodo'>,
|
|
410
391
|
roleId: string,
|
|
411
392
|
): Promise<TodoListState> {
|
|
412
|
-
const text =
|
|
393
|
+
const text = todoTextParam(params);
|
|
413
394
|
|
|
414
395
|
if (!text) {
|
|
415
396
|
throw new Error('Todo text is required');
|
|
416
397
|
}
|
|
417
398
|
|
|
418
|
-
await
|
|
399
|
+
await manager.create({
|
|
419
400
|
name: text,
|
|
420
|
-
|
|
401
|
+
completed: false,
|
|
421
402
|
});
|
|
422
403
|
|
|
423
|
-
return todoListState(await listTodos(
|
|
404
|
+
return todoListState(await listTodos(manager, roleId));
|
|
424
405
|
}
|
|
425
406
|
|
|
426
407
|
async function toggleTodo(
|
|
427
|
-
|
|
428
|
-
params: TodoPageFunctionParameters,
|
|
408
|
+
manager: TypedCustomObjectRecordManager<typeof todoDefinition>,
|
|
409
|
+
params: TypedSduiPageActionParams<TodoPageFunctionParameters, 'toggleTodo'>,
|
|
429
410
|
roleId: string,
|
|
430
411
|
): Promise<TodoListState> {
|
|
431
|
-
const todoId =
|
|
412
|
+
const todoId = todoIdParam(params);
|
|
432
413
|
|
|
433
414
|
if (!todoId) {
|
|
434
415
|
throw new Error('todoId must be a todo record ID');
|
|
435
416
|
}
|
|
436
417
|
|
|
437
|
-
const todo = toTodo(await
|
|
438
|
-
await
|
|
439
|
-
|
|
418
|
+
const todo = toTodo(await manager.get(todoId));
|
|
419
|
+
await manager.update(todoId, {
|
|
420
|
+
completed: !todo.completed,
|
|
440
421
|
});
|
|
441
422
|
|
|
442
|
-
return todoListState(await listTodos(
|
|
423
|
+
return todoListState(await listTodos(manager, roleId));
|
|
443
424
|
}
|
|
444
425
|
|
|
445
|
-
async function clearCompleted(
|
|
446
|
-
|
|
426
|
+
async function clearCompleted(
|
|
427
|
+
manager: TypedCustomObjectRecordManager<typeof todoDefinition>,
|
|
428
|
+
roleId: string,
|
|
429
|
+
): Promise<TodoListState> {
|
|
430
|
+
const todos = await listTodos(manager, roleId);
|
|
447
431
|
const completedTodoIds = todos.filter((todo) => todo.completed).map((todo) => todo.id);
|
|
448
432
|
|
|
449
433
|
if (completedTodoIds.length === 0) {
|
|
450
434
|
return todoListState(todos);
|
|
451
435
|
}
|
|
452
436
|
|
|
453
|
-
await
|
|
454
|
-
|
|
455
|
-
rows_to_delete: completedTodoIds,
|
|
437
|
+
await manager.deleteMany(completedTodoIds, {
|
|
438
|
+
allOrNothing: false,
|
|
456
439
|
});
|
|
457
440
|
|
|
458
|
-
return todoListState(await listTodos(
|
|
441
|
+
return todoListState(await listTodos(manager, roleId));
|
|
459
442
|
}
|
|
460
443
|
|
|
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
|
+
|
|
461
465
|
export async function onRipplingEvent(
|
|
462
|
-
event:
|
|
466
|
+
event: Input,
|
|
463
467
|
context: FunctionContext,
|
|
464
|
-
): Promise<FunctionResponse
|
|
465
|
-
|
|
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
|
-
}
|
|
468
|
+
): Promise<FunctionResponse<Output>> {
|
|
469
|
+
return todoPageHandler(event, context);
|
|
497
470
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed custom-object schema for the custom SDUI todo example.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { boolean, defineCustomObject, section } from '@rippling/rippling-sdk/core/platform/custom-objects';
|
|
6
|
+
|
|
7
|
+
/** Logical category shared by the custom SDUI todo example. */
|
|
8
|
+
export const CUSTOM_TODO_CATEGORY = 'custom_todo_app';
|
|
9
|
+
|
|
10
|
+
/** Typed schema used by the custom SDUI todo manifest and function code. */
|
|
11
|
+
export const todoDefinition = defineCustomObject({
|
|
12
|
+
name: 'todo',
|
|
13
|
+
displayName: 'Todo',
|
|
14
|
+
pluralLabel: 'Todos',
|
|
15
|
+
category: CUSTOM_TODO_CATEGORY,
|
|
16
|
+
description: 'A todo item rendered by a custom SDUI page.',
|
|
17
|
+
icon: { emoji: '✅' },
|
|
18
|
+
sections: {
|
|
19
|
+
details: section('Details', { sectionId: 'sec_custom_todo_details' }),
|
|
20
|
+
},
|
|
21
|
+
fields: {
|
|
22
|
+
completed: boolean({
|
|
23
|
+
displayName: 'Completed',
|
|
24
|
+
description: 'Whether the todo item is complete',
|
|
25
|
+
section: 'details',
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
});
|