@plitzi/sdk-shared 0.39.0 → 0.39.2
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/CHANGELOG.md +14 -0
- package/dist/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/actions/access.mjs +1 -2
- package/dist/actions/cron.mjs +1 -2
- package/dist/actions/failureHandler.mjs +1 -2
- package/dist/actions/flowDelay.d.ts +6 -0
- package/dist/actions/flowDelay.mjs +3 -0
- package/dist/actions/functions.d.ts +6 -3
- package/dist/actions/functions.mjs +12 -8
- package/dist/actions/index.d.ts +2 -1
- package/dist/actions/index.mjs +10 -9
- package/dist/actions/jobs.mjs +1 -2
- package/dist/actions/smtp.mjs +1 -2
- package/dist/actions/triggerParams.mjs +1 -2
- package/dist/actions/triggers.mjs +1 -2
- package/dist/actions/validateDocument.mjs +133 -123
- package/dist/activity/describe.mjs +1 -2
- package/dist/activity/guard.mjs +1 -2
- package/dist/activity/types.mjs +1 -2
- package/dist/auth/failureChannel.mjs +1 -2
- package/dist/auth/visitorRoles.mjs +1 -2
- package/dist/authoring/builder.mjs +1 -2
- package/dist/authoring/declare.mjs +1 -2
- package/dist/authoring/elementCallbacks.mjs +1 -2
- package/dist/authoring/index.mjs +3 -3
- package/dist/authoring/paramSpec.mjs +1 -2
- package/dist/authoring/spaceCallbacks.mjs +1 -2
- package/dist/builder/contexts/BuilderContext.mjs +1 -2
- package/dist/builder/contexts/index.mjs +1 -2
- package/dist/conditions/dates.d.ts +2 -0
- package/dist/conditions/dates.mjs +12 -0
- package/dist/conditions/evaluateRuleGroup.d.ts +13 -0
- package/dist/conditions/evaluateRuleGroup.mjs +4 -0
- package/dist/conditions/evaluator.d.ts +39 -0
- package/dist/conditions/evaluator.mjs +75 -0
- package/dist/conditions/index.d.ts +10 -0
- package/dist/conditions/index.mjs +5 -0
- package/dist/conditions/rules.d.ts +3 -0
- package/dist/conditions/rules.mjs +3 -0
- package/dist/conditions/types.d.ts +44 -0
- package/dist/connectors/constants.mjs +1 -2
- package/dist/connectors/manifestTokens.mjs +1 -2
- package/dist/connectors/presets.mjs +1 -2
- package/dist/connectors/validateManifest.mjs +56 -57
- package/dist/dataSource/computed.mjs +16 -17
- package/dist/dataSource/getBindingsDetails.d.ts +5 -6
- package/dist/dataSource/getBindingsDetails.mjs +65 -40
- package/dist/dataSource/globalSources.d.ts +1 -1
- package/dist/dataSource/globalSources.mjs +1 -2
- package/dist/dataSource/helpers/getSourceName.mjs +1 -2
- package/dist/dataSource/index.mjs +5 -5
- package/dist/dataSource/utility/arrayMap.mjs +2 -2
- package/dist/dataSource/utility/capitalize.mjs +1 -2
- package/dist/dataSource/utility/checkboxParams.mjs +1 -2
- package/dist/dataSource/utility/dateConverter.mjs +0 -1
- package/dist/dataSource/utility/index.mjs +15 -16
- package/dist/dataSource/utility/not.mjs +1 -2
- package/dist/dataSource/utility/staticValue.mjs +0 -1
- package/dist/dataSource/utility/stringToArray.mjs +0 -1
- package/dist/dataSource/utility/styleSelector.mjs +1 -2
- package/dist/dataSource/utility/styleVariant.mjs +2 -3
- package/dist/dataSource/utility/truthiness.mjs +1 -2
- package/dist/dataSource/utility/twigTemplate.mjs +0 -1
- package/dist/dataSource/variables/resolveVariables.mjs +2 -3
- package/dist/dates/formatDate.mjs +29 -30
- package/dist/dates/isDate.mjs +1 -2
- package/dist/devTools/chrome.mjs +1 -2
- package/dist/devTools/debugCookie.mjs +1 -2
- package/dist/devTools/index.mjs +5 -5
- package/dist/devTools/interactionLog.mjs +1 -2
- package/dist/devTools/react/DevToolsContext.mjs +1 -2
- package/dist/devTools/sight/sight.mjs +1 -2
- package/dist/devTools/utils/PlitziConsole.mjs +1 -2
- package/dist/elements/ComponentContext.mjs +1 -2
- package/dist/flags/flagsCookie.mjs +5 -6
- package/dist/flags/index.d.ts +1 -0
- package/dist/flags/index.mjs +4 -3
- package/dist/flags/overrides.d.ts +36 -0
- package/dist/flags/overrides.mjs +13 -0
- package/dist/flags/react/useFlagResolution.mjs +5 -6
- package/dist/flags/resolveFlags.d.ts +1 -1
- package/dist/flags/resolveFlags.mjs +2 -3
- package/dist/flags/schemaFlag.mjs +1 -2
- package/dist/functions/contract.d.ts +326 -0
- package/dist/functions/contract.mjs +3 -0
- package/dist/functions/index.d.ts +15 -0
- package/dist/functions/index.mjs +9 -0
- package/dist/functions/kv.d.ts +80 -0
- package/dist/functions/kvChange.d.ts +67 -0
- package/dist/functions/kvChange.mjs +24 -0
- package/dist/functions/later.d.ts +18 -0
- package/dist/functions/messages.d.ts +4 -0
- package/dist/functions/messages.mjs +205 -0
- package/dist/functions/protocol.d.ts +416 -0
- package/dist/functions/protocol.mjs +37 -0
- package/dist/functions/rateLimit.d.ts +17 -0
- package/dist/functions/rateLimit.mjs +0 -0
- package/dist/functions/refusal.d.ts +26 -0
- package/dist/functions/refusal.mjs +11 -0
- package/dist/functions/runtime.d.ts +44 -0
- package/dist/functions/runtime.mjs +13 -0
- package/dist/functions/sizes.d.ts +27 -0
- package/dist/functions/sizes.mjs +7 -0
- package/dist/functions/wire.d.ts +11 -0
- package/dist/functions/wire.mjs +39 -0
- package/dist/helpers/canonicalJson.mjs +1 -2
- package/dist/helpers/clipboard.mjs +1 -2
- package/dist/helpers/cookies.mjs +1 -2
- package/dist/helpers/deepEqual/deepEqual.d.ts +5 -0
- package/dist/helpers/deepEqual/deepEqual.mjs +44 -0
- package/dist/helpers/deepEqual/index.d.ts +1 -0
- package/dist/helpers/deepEqual/index.mjs +1 -0
- package/dist/helpers/eventTarget.mjs +1 -2
- package/dist/helpers/fetchManifest.mjs +1 -2
- package/dist/helpers/images.mjs +1 -2
- package/dist/helpers/index.d.ts +4 -6
- package/dist/helpers/index.mjs +24 -20
- package/dist/helpers/interval.mjs +1 -2
- package/dist/helpers/isRecord.mjs +1 -2
- package/dist/helpers/keys.mjs +1 -2
- package/dist/helpers/lodash/camelCase.d.ts +1 -0
- package/dist/helpers/lodash/camelCase.mjs +7 -0
- package/dist/helpers/lodash/capitalize.d.ts +1 -0
- package/dist/helpers/lodash/capitalize.mjs +5 -0
- package/dist/helpers/lodash/cloneDeep.d.ts +8 -0
- package/dist/helpers/lodash/cloneDeep.mjs +53 -0
- package/dist/helpers/lodash/get.d.ts +11 -0
- package/dist/helpers/lodash/get.mjs +14 -0
- package/dist/helpers/lodash/has.d.ts +2 -0
- package/dist/helpers/lodash/has.mjs +12 -0
- package/dist/helpers/lodash/index.d.ts +11 -0
- package/dist/helpers/lodash/index.mjs +7 -0
- package/dist/helpers/lodash/omit.d.ts +4 -0
- package/dist/helpers/lodash/omit.mjs +35 -0
- package/dist/helpers/lodash/set.d.ts +2 -0
- package/dist/helpers/lodash/set.mjs +20 -0
- package/dist/helpers/lodash/shared.d.ts +2 -0
- package/dist/helpers/lodash/shared.mjs +37 -0
- package/dist/helpers/reducerOrigin.mjs +1 -2
- package/dist/helpers/replaceEqualDeep/index.d.ts +1 -0
- package/dist/helpers/replaceEqualDeep/index.mjs +1 -0
- package/dist/helpers/replaceEqualDeep/replaceEqualDeep.d.ts +12 -0
- package/dist/helpers/replaceEqualDeep/replaceEqualDeep.mjs +30 -0
- package/dist/helpers/resources.d.ts +21 -0
- package/dist/helpers/resources.mjs +40 -0
- package/dist/helpers/scroll.mjs +1 -2
- package/dist/helpers/security.d.ts +15 -0
- package/dist/helpers/security.mjs +8 -4
- package/dist/helpers/spaceRoot.mjs +1 -2
- package/dist/helpers/syntaxHighlight.mjs +1 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +75 -76
- package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +1 -2
- package/dist/helpers/twigWrapper/Lexer/Lexer.mjs +1 -2
- package/dist/helpers/twigWrapper/Lexer/types.mjs +1 -2
- package/dist/helpers/twigWrapper/Parser/Cursor.mjs +1 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +1 -2
- package/dist/helpers/twigWrapper/Parser/Parser.mjs +1 -2
- package/dist/helpers/twigWrapper/Parser/helpers.mjs +1 -2
- package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +1 -2
- package/dist/helpers/twigWrapper/charClass.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/arrays.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/catalog/index.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/dateParts.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/dates.mjs +13 -14
- package/dist/helpers/twigWrapper/filters/filters.mjs +21 -22
- package/dist/helpers/twigWrapper/filters/hashing.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/misc.mjs +27 -28
- package/dist/helpers/twigWrapper/filters/numbers.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/objects.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/raw.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/strings.mjs +23 -24
- package/dist/helpers/twigWrapper/filters/types.mjs +1 -2
- package/dist/helpers/twigWrapper/filters/values.mjs +1 -2
- package/dist/helpers/twigWrapper/index.mjs +8 -8
- package/dist/helpers/twigWrapper/inspectTemplate.mjs +12 -13
- package/dist/helpers/twigWrapper/processTwig/helpers.mjs +1 -2
- package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +1 -2
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.mjs +1 -2
- package/dist/helpers/twigWrapper/templateRoots.d.ts +3 -9
- package/dist/helpers/twigWrapper/templateRoots.mjs +14 -9
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.mjs +1 -2
- package/dist/helpers/twigWrapper/tokens/hasValidToken.mjs +1 -2
- package/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs +1 -2
- package/dist/helpers/utils.mjs +2 -3
- package/dist/history/describe.mjs +1 -2
- package/dist/history/diff.mjs +1 -2
- package/dist/hooks/index.mjs +5 -5
- package/dist/hooks/useFontHead.mjs +1 -2
- package/dist/hooks/useNetwork.mjs +1 -2
- package/dist/hooks/usePlitzi.d.ts +7 -6
- package/dist/hooks/usePlitzi.mjs +1 -2
- package/dist/hooks/useStableValue.mjs +5 -6
- package/dist/navigation/index.mjs +3 -3
- package/dist/navigation/matchPath.mjs +19 -11
- package/dist/navigation/routes.mjs +57 -38
- package/dist/navigation/sitemap.mjs +9 -10
- package/dist/network/entitlements.d.ts +21 -0
- package/dist/network/entitlements.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddPluginMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpacePublishMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemovePluginMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceAddCdnBucketMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceAddCdnMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceRemoveCdnBucketMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceRemoveCdnMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceSetCdnCredentialMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceUpdateCdnBucketMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceUpdateCdnMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceAddConnectorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceRemoveConnectorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceUpdateConnectorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceAddCredentialMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceRemoveCredentialMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceUpdateCredentialMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/data/SpaceSaveDataMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/folders/SpaceAddPageFolderMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/folders/SpaceRemovePageFolderMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/folders/SpaceUpdatePageFolderMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceInstallTemplateFunctionsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/jobs/SpaceControlJobMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceHomePageMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceRemovePageMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/resources/SpaceAddResourceMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/resources/SpaceMoveResourceMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/resources/SpaceRemoveResourceMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/variables/SpaceAddVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/variables/SpaceRemoveVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/variables/SpaceUpdateVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/StyleUpdateMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/StyleUpdateSettingsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleAddSelectorVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleRemoveSelectorVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleUpdateSelectorVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleAddSelectorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleUpdateSelectorMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/variables/StyleAddVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/variables/StyleRemoveVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/Style/variables/StyleUpdateVariableMutation.mjs +1 -2
- package/dist/network/graphql/builder/Mutations/index.mjs +155 -156
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceCdnsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceConnectorsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceCredentialsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceDataQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceDeploymentsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.d.ts +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.mjs +2 -3
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceJobsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceLatestRevisionQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceResourcesQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.d.ts +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.mjs +2 -3
- package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/index.mjs +37 -38
- package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.mjs +1 -2
- package/dist/network/graphql/builder/Subscriptions/index.mjs +1 -2
- package/dist/network/graphql/builder/fragments/cdnFields.mjs +1 -2
- package/dist/network/graphql/index.d.ts +0 -1
- package/dist/network/graphql/index.mjs +1 -3
- package/dist/network/index.d.ts +1 -5
- package/dist/network/index.mjs +7 -11
- package/dist/network/{NetworkContext.d.ts → react/NetworkContext.d.ts} +12 -11
- package/dist/network/{NetworkContext.mjs → react/NetworkContext.mjs} +1 -2
- package/dist/network/{NetworkInternalContext.d.ts → react/NetworkInternalContext.d.ts} +1 -1
- package/dist/network/react/NetworkInternalContext.mjs +4 -0
- package/dist/network/react/index.d.ts +5 -0
- package/dist/network/react/index.mjs +3 -0
- package/dist/network/spaceEvents.mjs +16 -17
- package/dist/plugins/bundle/bundle.mjs +1 -2
- package/dist/plugins/declaration.mjs +1 -2
- package/dist/plugins/react/ElementRegistryContext.d.ts +26 -0
- package/dist/plugins/react/ElementRegistryContext.mjs +17 -0
- package/dist/plugins/react/PluginAssetsContext.d.ts +11 -0
- package/dist/plugins/react/PluginAssetsContext.mjs +4 -0
- package/dist/plugins/react/PluginsContext.mjs +6 -3
- package/dist/plugins/react/index.d.ts +3 -0
- package/dist/plugins/react/index.mjs +4 -1
- package/dist/project/index.mjs +7 -7
- package/dist/project/layout/check.mjs +26 -27
- package/dist/project/layout/codes.mjs +1 -2
- package/dist/project/layout/contents.mjs +12 -13
- package/dist/project/layout/files.mjs +1 -2
- package/dist/project/layout/folders.mjs +43 -44
- package/dist/project/layout/index.mjs +3 -3
- package/dist/project/layout/plugins.mjs +56 -57
- package/dist/project/layout/vendor.mjs +14 -15
- package/dist/project/network.mjs +1 -2
- package/dist/project/pages/index.mjs +1 -2
- package/dist/project/paths/index.d.ts +8 -2
- package/dist/project/paths/index.mjs +3 -4
- package/dist/project/root.mjs +1 -2
- package/dist/queries/index.mjs +1 -2
- package/dist/queries/queryCache.mjs +1 -2
- package/dist/queries/serverQueries.mjs +1 -2
- package/dist/queries/useQuery.mjs +1 -2
- package/dist/queries/useServerQuery.mjs +1 -2
- package/dist/{helpers → react}/enclosingSpace.mjs +1 -2
- package/dist/react/generateFacade.d.ts +1 -0
- package/dist/{helpers → react}/generateFacade.mjs +4 -5
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.mjs +4 -0
- package/dist/{helpers → react}/sharedContext.mjs +0 -1
- package/dist/realtime/client.mjs +3 -4
- package/dist/realtime/index.mjs +4 -4
- package/dist/realtime/presence.mjs +1 -2
- package/dist/realtime/topics.mjs +1 -2
- package/dist/runs/index.mjs +1 -2
- package/dist/runs/report.mjs +1 -2
- package/dist/schema/anchor.mjs +1 -2
- package/dist/schema/index.mjs +18 -18
- package/dist/schema/layoutChain.mjs +1 -2
- package/dist/schema/markdownHeadings.mjs +1 -2
- package/dist/schema/motion.mjs +1 -2
- package/dist/schema/motionReveal.mjs +1 -2
- package/dist/schema/pageAccess.d.ts +9 -0
- package/dist/schema/pageAccess.mjs +42 -36
- package/dist/schema/pageElements.d.ts +3 -1
- package/dist/schema/pageElements.mjs +9 -3
- package/dist/schema/pageHead.d.ts +5 -2
- package/dist/schema/pageHead.mjs +3 -4
- package/dist/schema/providerAnswer.mjs +1 -2
- package/dist/schema/providerWhen.d.ts +1 -1
- package/dist/schema/providerWhen.mjs +6 -7
- package/dist/schema/react/SchemaContext.mjs +1 -2
- package/dist/schema/schemaConstants.mjs +1 -2
- package/dist/schema/schemaSettings.d.ts +1 -1
- package/dist/schema/schemaSettings.mjs +2 -3
- package/dist/schema/serverElements.d.ts +0 -24
- package/dist/schema/serverElements.mjs +60 -39
- package/dist/schema/serverInput.mjs +23 -24
- package/dist/schema/serverQuery.d.ts +15 -5
- package/dist/schema/serverQuery.mjs +47 -35
- package/dist/schema/snippet.mjs +1 -2
- package/dist/schema/wire.mjs +1 -2
- package/dist/security/index.d.ts +49 -0
- package/dist/security/index.mjs +44 -0
- package/dist/server/actions/useActionsSync.mjs +1 -2
- package/dist/server/actions/useImagesSync.mjs +1 -2
- package/dist/server/actions/useRealtimeSync.mjs +1 -2
- package/dist/server/index.mjs +7 -7
- package/dist/server/rsc/refreshRsc.mjs +23 -24
- package/dist/server/rsc/useRscRefresh.mjs +1 -2
- package/dist/server/rsc/useRscSync.mjs +1 -2
- package/dist/server/usePluginRoute.mjs +1 -2
- package/dist/source/export.d.ts +1 -1
- package/dist/source/export.mjs +1 -2
- package/dist/source/import.mjs +1 -2
- package/dist/source/index.mjs +4 -4
- package/dist/source/snapshot.mjs +1 -2
- package/dist/state/index.d.ts +0 -1
- package/dist/state/index.mjs +1 -3
- package/dist/state/paintedState.d.ts +20 -4
- package/dist/state/paintedState.mjs +21 -21
- package/dist/store/actionRuns/actionRunsRecorder.mjs +1 -2
- package/dist/store/actionRuns/actionRunsStore.mjs +1 -2
- package/dist/store/actionRuns/index.mjs +3 -3
- package/dist/store/actionRuns/useActionRuns.mjs +5 -6
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.mjs +2 -1
- package/dist/store/renderSettings.d.ts +1 -1
- package/dist/store/renderSettings.mjs +1 -2
- package/dist/store/runtimeStatePersist.mjs +171 -0
- package/dist/store/storeHooks.d.ts +45 -45
- package/dist/store/storeHooks.mjs +1 -2
- package/dist/store/tracing/index.mjs +5 -5
- package/dist/store/tracing/preview.mjs +1 -2
- package/dist/store/tracing/tracingCollector.d.ts +2 -2
- package/dist/store/tracing/tracingCollector.mjs +79 -78
- package/dist/store/tracing/tracingMiddleware.mjs +1 -2
- package/dist/store/tracing/tracingStore.mjs +1 -2
- package/dist/store/tracing/useTracing.mjs +6 -7
- package/dist/style/breakpoints.mjs +1 -2
- package/dist/style/cssLayers.mjs +1 -2
- package/dist/style/displayModes.mjs +1 -2
- package/dist/style/fontAssets.mjs +1 -2
- package/dist/style/fontValidation.mjs +14 -15
- package/dist/style/fonts.d.ts +5 -3
- package/dist/style/fonts.mjs +23 -24
- package/dist/style/fontsFromCss.mjs +1 -2
- package/dist/style/index.mjs +18 -18
- package/dist/style/keyframes.mjs +1 -2
- package/dist/style/layoutGrid.mjs +1 -2
- package/dist/style/notifications.mjs +1 -2
- package/dist/style/react/useDisplayMode.mjs +1 -2
- package/dist/style/react/useElementSize.mjs +1 -2
- package/dist/style/runtimeStyle.d.ts +19 -21
- package/dist/style/runtimeStyle.mjs +4 -7
- package/dist/style/snippetStyle.mjs +5 -6
- package/dist/style/styleConditions.mjs +1 -2
- package/dist/style/styleConstants.mjs +1 -2
- package/dist/style/stylePseudos.mjs +1 -2
- package/dist/style/styleStates.mjs +1 -2
- package/dist/style/styleTarget.mjs +24 -25
- package/dist/theme/cookie/index.mjs +1 -1
- package/dist/theme/cookie/themeCookie.d.ts +21 -1
- package/dist/theme/cookie/themeCookie.mjs +19 -4
- package/dist/theme/index.d.ts +1 -9
- package/dist/theme/index.mjs +1 -6
- package/dist/theme/{ThemeProvider.d.ts → react/ThemeProvider.d.ts} +8 -2
- package/dist/theme/react/ThemeProvider.mjs +78 -0
- package/dist/theme/{ThemeScope.d.ts → react/ThemeScope.d.ts} +6 -2
- package/dist/theme/react/ThemeScope.mjs +9 -0
- package/dist/theme/react/index.d.ts +9 -0
- package/dist/theme/react/index.mjs +5 -0
- package/dist/theme/{themeStore.d.ts → react/themeStore.d.ts} +5 -5
- package/dist/theme/{themeStore.mjs → react/themeStore.mjs} +4 -4
- package/dist/theme/{useTheme.d.ts → react/useTheme.d.ts} +1 -1
- package/dist/theme/react/useTheme.mjs +19 -0
- package/dist/types/ActionTypes.d.ts +33 -0
- package/dist/types/AuthTypes.d.ts +6 -0
- package/dist/types/CommonTypes.d.ts +14 -3
- package/dist/types/DataSourceTypes.d.ts +1 -1
- package/dist/types/FunctionTypes.d.ts +16 -6
- package/dist/types/InteractionTypes.d.ts +1 -1
- package/dist/types/JobTypes.d.ts +56 -182
- package/dist/types/PluginTypes.d.ts +8 -1
- package/dist/types/SchemaTypes.d.ts +8 -1
- package/dist/types/SchemaTypes.mjs +1 -2
- package/dist/types/ServerAdapterTypes.d.ts +0 -326
- package/dist/types/ServerTypes.d.ts +0 -311
- package/dist/types/SpaceTypes.d.ts +5 -2
- package/dist/types/StoreTypes.d.ts +9 -3
- package/dist/types/StyleTypes.d.ts +6 -0
- package/dist/types/StyleTypes.mjs +1 -2
- package/dist/types/index.d.ts +0 -3
- package/dist/websockets/RTCodec.mjs +1 -2
- package/eslint.config.mjs +25 -0
- package/package.json +29 -18
- package/vite.config.ts +58 -0
- package/dist/helpers/generateFacade.d.ts +0 -2
- package/dist/helpers/ruleEvaluator.d.ts +0 -16
- package/dist/helpers/ruleEvaluator.mjs +0 -5
- package/dist/network/NetworkInternalContext.mjs +0 -5
- package/dist/network/graphql/sdk/Mutations/index.d.ts +0 -3
- package/dist/network/graphql/sdk/Mutations/index.mjs +0 -4
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +0 -16
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +0 -4
- package/dist/network/graphql/sdk/Queries/index.d.ts +0 -6
- package/dist/network/graphql/sdk/Queries/index.mjs +0 -5
- package/dist/network/graphql/sdk/index.d.ts +0 -5
- package/dist/network/graphql/sdk/index.mjs +0 -3
- package/dist/state/runtimeStatePersist.mjs +0 -119
- package/dist/theme/ThemeProvider.mjs +0 -69
- package/dist/theme/ThemeScope.mjs +0 -10
- package/dist/theme/useTheme.mjs +0 -20
- package/dist/types/OAuthTypes.d.ts +0 -246
- package/dist/types/ServerConfigTypes.d.ts +0 -527
- package/dist/types/ServerLogTypes.d.ts +0 -119
- /package/dist/{types/OAuthTypes.mjs → conditions/types.mjs} +0 -0
- /package/dist/{types/ServerConfigTypes.mjs → functions/kv.mjs} +0 -0
- /package/dist/{types/ServerLogTypes.mjs → functions/later.mjs} +0 -0
- /package/dist/{helpers → react}/enclosingSpace.d.ts +0 -0
- /package/dist/{helpers → react}/sharedContext.d.ts +0 -0
- /package/dist/{state → store}/runtimeStatePersist.d.ts +0 -0
package/dist/flags/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FLAG_GATE_PATTERN as e, FLAG_NAME_PATTERN as t, isFlagName as n, isSchemaFlag as r } from "./schemaFlag.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { FLAG_LAYERS as i, flagUserFrom as a, flagUserFromSSR as o, flagValues as s, hasConditions as c, passesFlagGate as l, resolveFlags as u, undeclaredFlagOverrides as d } from "./resolveFlags.mjs";
|
|
3
|
+
import { flagsCookieName as f, forcedFlagsFromCookies as p, parseFlagList as m, serializeFlagList as h, withForcedFlag as g, writeForcedFlags as _ } from "./flagsCookie.mjs";
|
|
4
|
+
import { forcedFlagsFor as v, requestFlagOverrides as y, serverFlagsFor as b } from "./overrides.mjs";
|
|
5
|
+
export { e as FLAG_GATE_PATTERN, i as FLAG_LAYERS, t as FLAG_NAME_PATTERN, a as flagUserFrom, o as flagUserFromSSR, s as flagValues, f as flagsCookieName, v as forcedFlagsFor, p as forcedFlagsFromCookies, c as hasConditions, n as isFlagName, r as isSchemaFlag, m as parseFlagList, l as passesFlagGate, y as requestFlagOverrides, u as resolveFlags, h as serializeFlagList, b as serverFlagsFor, d as undeclaredFlagOverrides, g as withForcedFlag, _ as writeForcedFlags };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FlagOverrides } from './resolveFlags';
|
|
2
|
+
import { Environment } from '../types';
|
|
3
|
+
/** What a request says of the flags a tester forced: its cookies, and the host it was addressed to (`requestAuthority`). */
|
|
4
|
+
export type FlagRequest = {
|
|
5
|
+
cookie: string | undefined;
|
|
6
|
+
authority: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The feature flags a deployment decides, by name — the `server` layer: above what each space declares, below the SDK
|
|
10
|
+
* embedding a page and a tester with the dev tools. A function when one server renders several spaces that do not share
|
|
11
|
+
* their flags: it is asked per render.
|
|
12
|
+
*/
|
|
13
|
+
export type ServerFlags = Record<string, boolean> | ((space: {
|
|
14
|
+
spaceId: number;
|
|
15
|
+
environment: Environment;
|
|
16
|
+
}) => Record<string, boolean>);
|
|
17
|
+
/** The deployment's own layer for one space: `config.flags`, asked per space when it is a function. */
|
|
18
|
+
export declare const serverFlagsFor: (config: {
|
|
19
|
+
flags?: ServerFlags;
|
|
20
|
+
}, space: {
|
|
21
|
+
spaceId: number;
|
|
22
|
+
environment: Environment;
|
|
23
|
+
}) => Record<string, boolean> | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The flags a tester forced from the dev tools, for a request allowed to debug — undefined for everybody else, and for
|
|
26
|
+
* a tester who forced nothing. Authorization is asked only when there is a cookie to honour, because answering it can
|
|
27
|
+
* mean reading the space.
|
|
28
|
+
*/
|
|
29
|
+
export declare const forcedFlagsFor: (req: FlagRequest, authorized: boolean | (() => Promise<boolean>)) => Promise<Record<string, boolean> | undefined>;
|
|
30
|
+
/** Both layers this server answers for, for one request. */
|
|
31
|
+
export declare const requestFlagOverrides: (config: {
|
|
32
|
+
flags?: ServerFlags;
|
|
33
|
+
}, req: FlagRequest, space: {
|
|
34
|
+
spaceId: number;
|
|
35
|
+
environment: Environment;
|
|
36
|
+
}, authorized: boolean | (() => Promise<boolean>)) => Promise<FlagOverrides>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { forcedFlagsFromCookies as e } from "./flagsCookie.mjs";
|
|
2
|
+
// src/flags/overrides.ts
|
|
3
|
+
var t = (e, t) => typeof e.flags == "function" ? e.flags(t) : e.flags, n = async (t, n) => {
|
|
4
|
+
let r = e(t.cookie, t.authority);
|
|
5
|
+
return Object.keys(r).length === 0 ? void 0 : (typeof n == "boolean" ? n : await n()) ? r : void 0;
|
|
6
|
+
}, r = async (e, r, i, a) => {
|
|
7
|
+
let o = t(e, i), s = await n(r, a);
|
|
8
|
+
return {
|
|
9
|
+
...o ? { server: o } : {},
|
|
10
|
+
...s ? { qa: s } : {}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export { n as forcedFlagsFor, r as requestFlagOverrides, t as serverFlagsFor };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import n from "
|
|
1
|
+
import e from "../../hooks/useStableValue.mjs";
|
|
2
|
+
import { flagUserFrom as t, resolveFlags as n } from "../resolveFlags.mjs";
|
|
3
3
|
import { useCommonStore as r } from "../../store/storeHooks.mjs";
|
|
4
4
|
import i from "../../store/renderSettings.mjs";
|
|
5
5
|
import { useMemo as a } from "react";
|
|
6
|
-
|
|
6
|
+
// src/flags/react/useFlagResolution.ts
|
|
7
7
|
var o = (o) => {
|
|
8
8
|
let { environment: s } = i(), [[c, l, u, d, f]] = r([
|
|
9
9
|
"schema.flags",
|
|
@@ -11,11 +11,11 @@ var o = (o) => {
|
|
|
11
11
|
"navigation.queryParams",
|
|
12
12
|
"navigation.hostname",
|
|
13
13
|
"flags.overrides"
|
|
14
|
-
]), { authenticated: p, user: m } = o, h = a(() =>
|
|
14
|
+
]), { authenticated: p, user: m } = o, h = a(() => t({
|
|
15
15
|
authenticated: p,
|
|
16
16
|
user: m
|
|
17
17
|
}), [p, m]);
|
|
18
|
-
return
|
|
18
|
+
return e(a(() => n(c, {
|
|
19
19
|
environment: s,
|
|
20
20
|
hostname: d,
|
|
21
21
|
routeParams: l,
|
|
@@ -31,5 +31,4 @@ var o = (o) => {
|
|
|
31
31
|
f
|
|
32
32
|
]));
|
|
33
33
|
};
|
|
34
|
-
//#endregion
|
|
35
34
|
export { o as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { RuleGroup } from '../conditions';
|
|
1
2
|
import { VariableScope } from '../dataSource/variables';
|
|
2
|
-
import { RuleGroup } from '../helpers/ruleEvaluator';
|
|
3
3
|
import { AuthContextValue, Schema, SSRUser } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Who decided a flag, weakest first: the space's own declaration, then the server rendering it, then the SDK
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { evaluateRuleGroup as e } from "../
|
|
2
|
-
|
|
1
|
+
import { evaluateRuleGroup as e } from "../conditions/evaluateRuleGroup.mjs";
|
|
2
|
+
// src/flags/resolveFlags.ts
|
|
3
3
|
var t = [
|
|
4
4
|
"space",
|
|
5
5
|
"server",
|
|
@@ -42,5 +42,4 @@ var t = [
|
|
|
42
42
|
layer: n,
|
|
43
43
|
name: e
|
|
44
44
|
}))), d = (e, t) => !e || (t[e.name] ?? !1) === e.is;
|
|
45
|
-
//#endregion
|
|
46
45
|
export { t as FLAG_LAYERS, n as flagUserFrom, r as flagUserFromSSR, l as flagValues, a as hasConditions, d as passesFlagGate, c as resolveFlags, u as undeclaredFlagOverrides };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { isRecord as e } from "../helpers/isRecord.mjs";
|
|
2
|
-
|
|
2
|
+
// src/flags/schemaFlag.ts
|
|
3
3
|
var t = "[A-Za-z_][A-Za-z0-9_]*", n = RegExp(`^${t}$`), r = RegExp(`^!?${t}$`), i = /* @__PURE__ */ new Set([
|
|
4
4
|
"__proto__",
|
|
5
5
|
"constructor",
|
|
6
6
|
"prototype"
|
|
7
7
|
]), a = (e) => n.test(e) && !i.has(e), o = (t) => e(t) && typeof t.value == "boolean" && (t.description === void 0 || typeof t.description == "string") && Array.isArray(t.rules) && t.rules.every((t) => e(t) && typeof t.value == "boolean" && e(t.when));
|
|
8
|
-
//#endregion
|
|
9
8
|
export { r as FLAG_GATE_PATTERN, n as FLAG_NAME_PATTERN, a as isFlagName, o as isSchemaFlag };
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { ActionKvStore } from './kv';
|
|
2
|
+
import { LaterAnswer, LaterRequest } from './later';
|
|
3
|
+
import { RateCount, RateLimit } from './rateLimit';
|
|
4
|
+
import { ActionAccess, Environment, FunctionJobView, FunctionOAuthConnection, FunctionAskedLimits, InteractionCallbackParam } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Who started the run, as a space's own code may know them: everything a function decides by — who, their roles and
|
|
7
|
+
* permissions — and never their session. A token inside the sandbox is a token a function could send anywhere.
|
|
8
|
+
*/
|
|
9
|
+
export type FunctionUser = {
|
|
10
|
+
id: number;
|
|
11
|
+
username: string;
|
|
12
|
+
email: string;
|
|
13
|
+
verified: boolean;
|
|
14
|
+
permissions: string[];
|
|
15
|
+
roles: string[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A request a function makes: `fetch`'s own init, and `credential` — the id of one of the space's credentials, whose
|
|
19
|
+
* values the platform writes into the request where it says `{{credential.<key>}}` (in the URL, a header or the
|
|
20
|
+
* body). The code never holds the value; it names it.
|
|
21
|
+
*/
|
|
22
|
+
export type FunctionFetchInit = {
|
|
23
|
+
method?: string;
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
body?: string;
|
|
26
|
+
credential?: string;
|
|
27
|
+
/** Cuts the request short when it aborts (`AbortSignal.timeout(12_000)`); the run's own end cuts it regardless. */
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
};
|
|
30
|
+
/** What a function's `fetch` answers: a web `Response`, whichever runner it is in. */
|
|
31
|
+
export type FunctionFetch = (url: string | URL, init?: FunctionFetchInit) => Promise<Response>;
|
|
32
|
+
/**
|
|
33
|
+
* Whose an OAuth connection is: a signed-in visitor's own by default (`user:<id>`); `space` for one the whole space
|
|
34
|
+
* shares; or a key the code keeps for whom it serves — a profile, a team (`profile:ana`). Letters, digits and `:._@-`.
|
|
35
|
+
*/
|
|
36
|
+
export type FunctionOAuthOwner = {
|
|
37
|
+
owner?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The `code` of a refusal `ctx.oauth` throws (an `ActionRefusal`), to tell it apart by: `oauth-not-connected` — no
|
|
41
|
+
* account connected for that owner yet, so `connect` first; `oauth-no-owner` — nobody signed in and no `owner` named.
|
|
42
|
+
*/
|
|
43
|
+
export type FunctionOAuthRefusal = 'oauth-not-connected' | 'oauth-no-owner';
|
|
44
|
+
/** What `ctx.oauth.status` says of a connection — never its token. */
|
|
45
|
+
export type FunctionOAuthStatus = {
|
|
46
|
+
connected: boolean;
|
|
47
|
+
scopes?: string[];
|
|
48
|
+
expiresAt?: number;
|
|
49
|
+
};
|
|
50
|
+
/** The access token `ctx.oauth.token` hands out — never the refresh token, which stays with the platform. */
|
|
51
|
+
export type FunctionOAuthToken = {
|
|
52
|
+
token: string;
|
|
53
|
+
type: string;
|
|
54
|
+
expiresAt?: number;
|
|
55
|
+
scopes?: string[];
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* OAuth 2.0 on behalf of whoever the space serves, through the connections it declared (`oauth` in its functions): the
|
|
59
|
+
* consent, the code exchanged, the token kept sealed and renewed by the platform. The code never holds a token, as it
|
|
60
|
+
* never holds a credential — it names the connection.
|
|
61
|
+
*/
|
|
62
|
+
export type FunctionOAuth = {
|
|
63
|
+
/**
|
|
64
|
+
* Where to send the visitor to consent (authorization code, PKCE). They come back to `/fn/oauth/callback` — the
|
|
65
|
+
* address to register with the provider, on the space's host — and from there to `returnTo`, a path of the space,
|
|
66
|
+
* with `?oauth=<connection>&oauth_result=connected` or `&oauth_error=<what>`. `authorizeParams` adds to the
|
|
67
|
+
* connection's for this consent alone — `{ prompt: 'select_account' }` to choose another account — never one the
|
|
68
|
+
* platform writes (`state`, `redirect_uri`, `scope`, PKCE's).
|
|
69
|
+
*/
|
|
70
|
+
connect: (connection: string, options: {
|
|
71
|
+
returnTo: string;
|
|
72
|
+
authorizeParams?: Record<string, string>;
|
|
73
|
+
} & FunctionOAuthOwner) => Promise<{
|
|
74
|
+
url: string;
|
|
75
|
+
}>;
|
|
76
|
+
status: (connection: string, options?: FunctionOAuthOwner) => Promise<FunctionOAuthStatus>;
|
|
77
|
+
/**
|
|
78
|
+
* A request to the provider's API with the token written in (`Authorization: Bearer`), renewed when it is about to
|
|
79
|
+
* lapse and once more if the answer is 401. Only to the hosts the space declared (`allow.hosts`). With nobody
|
|
80
|
+
* connected it refuses, `code: 'oauth-not-connected'` ({@link FunctionOAuthRefusal}).
|
|
81
|
+
*/
|
|
82
|
+
fetch: (connection: string, url: string | URL, init?: Omit<FunctionFetchInit, 'credential'> & FunctionOAuthOwner) => Promise<Response>;
|
|
83
|
+
/** Forgets the connection — revoked at the provider when it says where — and answers whether there was one. */
|
|
84
|
+
disconnect: (connection: string, options?: FunctionOAuthOwner) => Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* The access token itself, renewed first when it is about to lapse — only of a connection that declares
|
|
87
|
+
* `exposeToken: true`, for a provider's SDK in the page that asks for it (`getOAuthToken`). Whoever the code hands it
|
|
88
|
+
* to holds it until it lapses: answer it only to whom the connection is (its owner), from a route that checks so.
|
|
89
|
+
*/
|
|
90
|
+
token: (connection: string, options?: FunctionOAuthOwner) => Promise<FunctionOAuthToken>;
|
|
91
|
+
/**
|
|
92
|
+
* The address providers send a visitor back to (`…/fn/oauth/callback`) — the one this run's `connect` hands them, to
|
|
93
|
+
* show whoever registers the app with a provider. The space's host the request came on, or the one the deployment
|
|
94
|
+
* fixed (`functions.oauth.callbackOrigin`); refused in a run no visitor's request started, when none was fixed.
|
|
95
|
+
*/
|
|
96
|
+
callbackUrl: () => Promise<string>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The space's jobs, from its code: what starts one, reads it and stops it. Who may is the code's to decide — these are
|
|
100
|
+
* called from its routes and tasks, behind its own checks.
|
|
101
|
+
*/
|
|
102
|
+
export type FunctionJobs = {
|
|
103
|
+
/**
|
|
104
|
+
* Starts one of the jobs this code declares (`jobs` in `defineFunctions`), with `input`: answered at once, the job
|
|
105
|
+
* `pending`. With `key`, at most one of that key runs at a time — starting it again while one is under way answers that
|
|
106
|
+
* one (a button pressed twice), and once it ended starts it over with the new input.
|
|
107
|
+
*/
|
|
108
|
+
start: (name: string, input?: Record<string, unknown>, options?: {
|
|
109
|
+
key?: string;
|
|
110
|
+
}) => Promise<FunctionJobView>;
|
|
111
|
+
/** One of the space's jobs, as whoever may watch it sees it — or nothing, when there is none by that id. */
|
|
112
|
+
get: (id: string) => Promise<FunctionJobView | undefined>;
|
|
113
|
+
/** Sets it aside: it stops once its code saved, and waits as `paused`. Answers whether anything changed. */
|
|
114
|
+
pause: (id: string) => Promise<boolean>;
|
|
115
|
+
/** Puts a paused job back in the queue, to go on from what it saved. */
|
|
116
|
+
resume: (id: string) => Promise<boolean>;
|
|
117
|
+
/** Stops it for good: dropped if it waits, aborted if it runs. */
|
|
118
|
+
cancel: (id: string) => Promise<boolean>;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Why a slice of a job is asked to end (`job.stopping`): it was set aside (`pause`) or cancelled (`cancel`), its time in
|
|
122
|
+
* one go is up (`limit`) or the server is going away (`shutdown`). Whichever, what was saved is where it goes on from.
|
|
123
|
+
*/
|
|
124
|
+
export type FunctionJobStop = 'pause' | 'cancel' | 'limit' | 'shutdown';
|
|
125
|
+
/**
|
|
126
|
+
* What a job's `run` is handed besides its input: the job, and how it keeps where it is. A job runs in slices — a pause,
|
|
127
|
+
* a lost server or its time in one go ending one — and every slice but the first starts from what the one before saved.
|
|
128
|
+
*/
|
|
129
|
+
export type FunctionJobHandle<S = unknown> = {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
/** What it last saved — `undefined` on its first slice, and whenever it never saved. */
|
|
133
|
+
state: S | undefined;
|
|
134
|
+
/** Which attempt this is, from 1: a slice after a failure is the next attempt, from the last save. */
|
|
135
|
+
attempt: number;
|
|
136
|
+
/**
|
|
137
|
+
* Keeps `state` durably: the next slice starts with it. JSON, within what the server keeps for one job. A method, not
|
|
138
|
+
* a property: so a job whose state has a type of its own is still one of `FunctionsDefinition['jobs']`.
|
|
139
|
+
*/
|
|
140
|
+
save(state: S): Promise<void>;
|
|
141
|
+
/** How far it is, from 0 to 1, and what it is doing — for whoever watches it. Never fails the job. */
|
|
142
|
+
report: (fraction: number, step?: string) => void;
|
|
143
|
+
/** Why this slice is asked to end, once it is (`signal` aborted): save, and return. */
|
|
144
|
+
readonly stopping: FunctionJobStop | undefined;
|
|
145
|
+
/** Aborted when the slice is asked to end — the same as `ctx.signal`. Some seconds later it is cut. */
|
|
146
|
+
signal: AbortSignal;
|
|
147
|
+
};
|
|
148
|
+
/** A job of the space's: work longer than a request, run on the server slice by slice until it answers. */
|
|
149
|
+
export type FunctionJob<I extends Record<string, unknown> = Record<string, unknown>, S = unknown, R = unknown> = {
|
|
150
|
+
/**
|
|
151
|
+
* Who may watch it (`$job:<id>`, `useJob`) besides whoever started it — a channel's access, read against the visitor's
|
|
152
|
+
* permissions in the space. Absent, only whoever started it.
|
|
153
|
+
*/
|
|
154
|
+
watch?: ActionAccess;
|
|
155
|
+
/** How long it may run, every slice together, in seconds — within what the server allows. */
|
|
156
|
+
maxSeconds?: number;
|
|
157
|
+
/**
|
|
158
|
+
* The work. What it answers is the job's result; an `ActionRefusal` fails it without a retry. A method, not a property:
|
|
159
|
+
* so a job typed with an input and a state of its own is still one of `FunctionsDefinition['jobs']`, and one written
|
|
160
|
+
* in place there gets an object for its input and `unknown` for its state.
|
|
161
|
+
*/
|
|
162
|
+
run(input: I, job: FunctionJobHandle<S>, ctx: FunctionContext): R | Promise<R>;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* A person of the space as another's code may read them: who they are to a page — never their email, their roles or
|
|
166
|
+
* anything they did not show. `name` and `avatar` where the deployment keeps them.
|
|
167
|
+
*/
|
|
168
|
+
export type FunctionVisitor = {
|
|
169
|
+
id: number;
|
|
170
|
+
username: string;
|
|
171
|
+
name?: string;
|
|
172
|
+
avatar?: string;
|
|
173
|
+
};
|
|
174
|
+
/** Who is on a presence channel's topic: how many, and each page with who is signed in on it. */
|
|
175
|
+
export type FunctionPresence = {
|
|
176
|
+
count: number;
|
|
177
|
+
members: {
|
|
178
|
+
from: string;
|
|
179
|
+
user?: {
|
|
180
|
+
id: number;
|
|
181
|
+
name: string;
|
|
182
|
+
};
|
|
183
|
+
since: number;
|
|
184
|
+
}[];
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Everything a space's code can do besides computing — one object, the same wherever it runs. In a self-hosted server
|
|
188
|
+
* it is built from the run's own context; in the sandbox each method is a call back to the platform, which scopes it
|
|
189
|
+
* to the space and the run before doing it.
|
|
190
|
+
*/
|
|
191
|
+
export type FunctionContext = {
|
|
192
|
+
spaceId: number;
|
|
193
|
+
environment: Environment;
|
|
194
|
+
runId: string;
|
|
195
|
+
/** How the run was started: `call`, `render`, `schedule`, `webhook`… */
|
|
196
|
+
trigger: string;
|
|
197
|
+
/** `user:<id>` for a session, `ip:<address>` for everyone else — what a limit per person keys on. */
|
|
198
|
+
callerId: string;
|
|
199
|
+
user?: FunctionUser;
|
|
200
|
+
/**
|
|
201
|
+
* The space's own key/value store: `get`, `set`, `swap`, `increment`, lists — and `change`, to read, change and write
|
|
202
|
+
* a value back without undoing a writer that got there first.
|
|
203
|
+
*/
|
|
204
|
+
kv: ActionKvStore;
|
|
205
|
+
/**
|
|
206
|
+
* Counts one more of `bucket` — per caller unless `per: 'everyone'` — and says whether it was within `most` in every
|
|
207
|
+
* `perSeconds`. The same count as a flow's `flow.rateLimit` step on that bucket. What to answer when it is not is the
|
|
208
|
+
* code's.
|
|
209
|
+
*/
|
|
210
|
+
rateLimit: (bucket: string, limit: RateLimit) => Promise<RateCount>;
|
|
211
|
+
/**
|
|
212
|
+
* Signs `value` with a key of the space's own that the platform keeps and the code never sees: HMAC-SHA-256,
|
|
213
|
+
* base64url. What a link, an invitation or a key handed to a page is made of. Refused on a server with no signing
|
|
214
|
+
* secret.
|
|
215
|
+
*/
|
|
216
|
+
sign: (value: string) => Promise<string>;
|
|
217
|
+
/** Whether `signature` is what `sign` answered for `value`, compared in constant time. */
|
|
218
|
+
verify: (value: string, signature: string) => Promise<boolean>;
|
|
219
|
+
/** To the hosts the space declared (`allow.hosts`) — and, with `credential`, with one of its secrets written in. */
|
|
220
|
+
fetch: FunctionFetch;
|
|
221
|
+
/** Says something on one of the space's realtime channels, as the server. */
|
|
222
|
+
publish: (topic: string, type: string, data: unknown) => Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Who is on a topic of one of the space's `presence: true` channels now — every page connected to it, on whichever
|
|
225
|
+
* replica — the earliest arrived first. A room's listeners, counted by the server rather than by what pages report.
|
|
226
|
+
*/
|
|
227
|
+
presence: (topic: string) => Promise<FunctionPresence>;
|
|
228
|
+
/**
|
|
229
|
+
* The space's people, read by another: `get('mika')` or `get(7)` — public fields alone, and only of someone who
|
|
230
|
+
* belongs to the space (the deployment says who: its visitors and members on Plitzi, every account of its own on a
|
|
231
|
+
* server of yours). `undefined` for anyone else, never "exists elsewhere": a profile page, a chat's names.
|
|
232
|
+
*/
|
|
233
|
+
visitors: {
|
|
234
|
+
get: (who: string | number) => Promise<FunctionVisitor | undefined>;
|
|
235
|
+
};
|
|
236
|
+
/** Lets the visitor into one topic of a private (`grant: true`) channel. */
|
|
237
|
+
grant: (topic: string, ttlSeconds?: number) => Promise<string>;
|
|
238
|
+
/** Takes a grant back — or every grant for the topic, naming none. */
|
|
239
|
+
revoke: (topic: string, grant?: string) => Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Starts one of the space's actions — one with a `later` trigger — in so many seconds, on the server, whether or not a
|
|
242
|
+
* page is still open: a turn that runs out, a bot's move, a hold that lapses. A `key` names it: set again under the
|
|
243
|
+
* same key, the one still waiting is replaced. Answers the job and when it is due (epoch ms, by the queue's clock).
|
|
244
|
+
* `ctx.later({ action: 'game.timeout', in: 45, input: { room }, key: 'turn:' + room })`.
|
|
245
|
+
*/
|
|
246
|
+
later: (request: LaterRequest) => Promise<LaterAnswer>;
|
|
247
|
+
/** Drops what waits under `key` — the timer of a game that ended — and answers how many. */
|
|
248
|
+
cancelLater: (key: string) => Promise<number>;
|
|
249
|
+
/**
|
|
250
|
+
* One file of the space's data — a project's `src/data/<file>` — parsed, as of the version the run belongs to: what
|
|
251
|
+
* a page must not carry, read here and answered only as far as it is shown. Read-only. `ctx.data('products.json')`.
|
|
252
|
+
*/
|
|
253
|
+
data: (file: string) => Promise<unknown>;
|
|
254
|
+
/** A line for whoever reads the run: the builder's Try, and the deployment's logs. */
|
|
255
|
+
log: (...values: unknown[]) => void;
|
|
256
|
+
/** OAuth 2.0 through the space's declared connections — see {@link FunctionOAuth}. */
|
|
257
|
+
oauth: FunctionOAuth;
|
|
258
|
+
/** The space's jobs — see {@link FunctionJobs}. */
|
|
259
|
+
jobs: FunctionJobs;
|
|
260
|
+
/** Progress for a caller that asked for a stream — a no-op when nobody did. */
|
|
261
|
+
emit: (chunk: unknown) => void;
|
|
262
|
+
/** Aborted when the run is: cancelled, or out of time. Hand it to what can stop early. */
|
|
263
|
+
signal: AbortSignal;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* One step a server action can take, written by the space. The shape of the platform's own tasks — addressed as
|
|
267
|
+
* `<namespace>.<action>`, drawn in the builder from `params` — run with a {@link FunctionContext} rather than the
|
|
268
|
+
* platform's full one.
|
|
269
|
+
*
|
|
270
|
+
* `R` is what `run` answers: `taskAction(task, …)` hands it, with `T`, to a page that runs the action
|
|
271
|
+
* (`useServerAction`), so `FunctionTask<{ id: string }, Habit>` is typed at both ends.
|
|
272
|
+
*/
|
|
273
|
+
export type FunctionTask<T extends Record<string, unknown> = Record<string, unknown>, R = unknown> = {
|
|
274
|
+
namespace: string;
|
|
275
|
+
action: string;
|
|
276
|
+
title: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
params: Record<keyof T, InteractionCallbackParam<T>>;
|
|
279
|
+
/**
|
|
280
|
+
* More CPU, time or memory than an invocation gets by default — `{ cpuMs: 1000, size: 'medium' }` for a task that
|
|
281
|
+
* reshapes a big feed — up to what the space's plan and the server allow. Over the functions' own `limits`, for this
|
|
282
|
+
* task.
|
|
283
|
+
*/
|
|
284
|
+
limits?: FunctionAskedLimits;
|
|
285
|
+
run: (params: T, ctx: FunctionContext) => R | Promise<R>;
|
|
286
|
+
};
|
|
287
|
+
/** What a route's handler gets besides the request: the context, and the `:params` its key named, by name. */
|
|
288
|
+
export type FunctionRouteContext = FunctionContext & {
|
|
289
|
+
params: Record<string, string>;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* An HTTP endpoint of the space, under `/fn/`: a web-standard handler, the shape every edge runtime runs. The request
|
|
293
|
+
* carries no credentials — `ctx.user` says who is asking — and the response sets no cookies: the host's are the
|
|
294
|
+
* platform's.
|
|
295
|
+
*/
|
|
296
|
+
export type FunctionRoute = (request: Request, ctx: FunctionRouteContext) => Response | Promise<Response>;
|
|
297
|
+
/**
|
|
298
|
+
* What each file at the top of a space's `functions/` exports by default — its tasks, its routes, and where its code
|
|
299
|
+
* may reach — merged into the one definition a bundle exports (`mergeFunctions`).
|
|
300
|
+
*/
|
|
301
|
+
export type FunctionsDefinition = {
|
|
302
|
+
/** The hosts `ctx.fetch` may reach. Anything else is refused before it leaves. */
|
|
303
|
+
allow?: {
|
|
304
|
+
hosts?: string[];
|
|
305
|
+
};
|
|
306
|
+
tasks?: FunctionTask<never>[];
|
|
307
|
+
/** `'GET /board-assets/:board/:asset'` → a handler, served at `/fn/board-assets/…`. */
|
|
308
|
+
routes?: Record<string, FunctionRoute>;
|
|
309
|
+
/**
|
|
310
|
+
* More CPU, time or memory than an invocation gets by default, for every task and route — a task may ask for its
|
|
311
|
+
* own.
|
|
312
|
+
*/
|
|
313
|
+
limits?: FunctionAskedLimits;
|
|
314
|
+
/**
|
|
315
|
+
* The OAuth connections its code makes (`ctx.oauth`), by the name it calls them — any provider, as data: its `issuer`
|
|
316
|
+
* (OpenID) or its endpoints, the credential with the app's id and secret, the scopes.
|
|
317
|
+
*/
|
|
318
|
+
oauth?: Record<string, FunctionOAuthConnection>;
|
|
319
|
+
/** Its jobs, by name (`ctx.jobs.start(name, input)`): work that outlives a request, run slice by slice. */
|
|
320
|
+
jobs?: Record<string, FunctionJob>;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Declares a space's functions. An identity at run time: it is here for the types, and so the same file is valid
|
|
324
|
+
* wherever it is loaded — natively in a self-hosted server, or built by the platform and run in its sandbox.
|
|
325
|
+
*/
|
|
326
|
+
export declare const defineFunctions: (definition: FunctionsDefinition) => FunctionsDefinition;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type { FunctionContext, FunctionFetch, FunctionFetchInit, FunctionJob, FunctionJobHandle, FunctionJobs, FunctionJobStop, FunctionOAuth, FunctionOAuthOwner, FunctionOAuthRefusal, FunctionOAuthStatus, FunctionOAuthToken, FunctionPresence, FunctionRoute, FunctionRouteContext, FunctionsDefinition, FunctionTask, FunctionUser, FunctionVisitor } from './contract';
|
|
2
|
+
export { defineFunctions } from './contract';
|
|
3
|
+
export type { ActionKvStore, KvListEntry, KvListPut, KvListPutOptions, KvListRange } from './kv';
|
|
4
|
+
export { changeKv, changeListEntry } from './kvChange';
|
|
5
|
+
export type { KvChangeLifetime, KvChangeOptions, KvChangeStore, KvListChangeStore } from './kvChange';
|
|
6
|
+
export type { LaterAnswer, LaterRequest } from './later';
|
|
7
|
+
export { readRequestMessage, readResponseMessage } from './messages';
|
|
8
|
+
export { errorOfAnswer, failedAnswerOf, FUNCTIONS_PROTOCOL, FunctionFailure, isFunctionLimit, invocationUrgency, isStreamedRouteAnswer, protocolKnows, protocolRefusal } from './protocol';
|
|
9
|
+
export type { FunctionAnswer, FunctionCall, FunctionFailureReason, FunctionInvocation, FunctionInvocationContext, FunctionInvokeRequest, FunctionJobSlice, FunctionLimitReason, FunctionLimits, FunctionRunner, FunctionsBundle, FunctionsBundleRef, FunctionStopReason, FunctionUrgency, FunctionUsage, RunnerRequestMessage, RunnerResponseMessage, SpaceFunctions, StreamedRouteAnswer, WireBody, WireFetchInit, WireHeaders, WireRequest, WireResponse } from './protocol';
|
|
10
|
+
export type { RateCount, RateLimit } from './rateLimit';
|
|
11
|
+
export { ActionRefusal, isActionRefusal, refusalCodeOf } from './refusal';
|
|
12
|
+
export { bodyOf, requestFromWire, responseOf, wireBodyOf, wireRequestOf, wireResponseFrom, wireResponseOf } from './wire';
|
|
13
|
+
export { endpointFor, endpointProblem, PLATFORM_HEADERS, RUNTIME_DESCRIBE_PATH } from './runtime';
|
|
14
|
+
export { FUNCTION_SIZE_NAMES, FUNCTION_SIZES, functionSizeOfMemory, functionSizesWithin, isFunctionSize, largerFunctionSize } from './sizes';
|
|
15
|
+
export type { SpaceRuntime, SpaceRuntimeContext, SpaceRuntimeEndpoint, SpaceRuntimeParts } from './runtime';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineFunctions as e } from "./contract.mjs";
|
|
2
|
+
import { changeKv as t, changeListEntry as n } from "./kvChange.mjs";
|
|
3
|
+
import { readRequestMessage as r, readResponseMessage as i } from "./messages.mjs";
|
|
4
|
+
import { FUNCTIONS_PROTOCOL as a, FunctionFailure as o, errorOfAnswer as s, failedAnswerOf as c, invocationUrgency as l, isFunctionLimit as u, isStreamedRouteAnswer as d, protocolKnows as f, protocolRefusal as p } from "./protocol.mjs";
|
|
5
|
+
import { ActionRefusal as m, isActionRefusal as h, refusalCodeOf as g } from "./refusal.mjs";
|
|
6
|
+
import { bodyOf as _, requestFromWire as v, responseOf as y, wireBodyOf as b, wireRequestOf as x, wireResponseFrom as S, wireResponseOf as C } from "./wire.mjs";
|
|
7
|
+
import { PLATFORM_HEADERS as w, RUNTIME_DESCRIBE_PATH as T, endpointFor as E, endpointProblem as D } from "./runtime.mjs";
|
|
8
|
+
import { FUNCTION_SIZES as O, FUNCTION_SIZE_NAMES as k, functionSizeOfMemory as A, functionSizesWithin as j, isFunctionSize as M, largerFunctionSize as N } from "./sizes.mjs";
|
|
9
|
+
export { m as ActionRefusal, a as FUNCTIONS_PROTOCOL, O as FUNCTION_SIZES, k as FUNCTION_SIZE_NAMES, o as FunctionFailure, w as PLATFORM_HEADERS, T as RUNTIME_DESCRIBE_PATH, _ as bodyOf, t as changeKv, n as changeListEntry, e as defineFunctions, E as endpointFor, D as endpointProblem, s as errorOfAnswer, c as failedAnswerOf, A as functionSizeOfMemory, j as functionSizesWithin, l as invocationUrgency, h as isActionRefusal, u as isFunctionLimit, M as isFunctionSize, d as isStreamedRouteAnswer, N as largerFunctionSize, f as protocolKnows, p as protocolRefusal, r as readRequestMessage, i as readResponseMessage, g as refusalCodeOf, v as requestFromWire, y as responseOf, b as wireBodyOf, x as wireRequestOf, S as wireResponseFrom, C as wireResponseOf };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { KvChangeLifetime } from './kvChange';
|
|
2
|
+
/** One entry of a list: what it is called, where it sorts, and what it carries. */
|
|
3
|
+
export type KvListEntry = {
|
|
4
|
+
id: string;
|
|
5
|
+
score: number;
|
|
6
|
+
value: unknown;
|
|
7
|
+
};
|
|
8
|
+
export type KvListRange = {
|
|
9
|
+
/** How many entries to skip first. 0 when absent. */
|
|
10
|
+
offset?: number;
|
|
11
|
+
/** How many to answer. All of them when absent. */
|
|
12
|
+
limit?: number;
|
|
13
|
+
/** `desc` — the highest score first — when absent. */
|
|
14
|
+
order?: 'asc' | 'desc';
|
|
15
|
+
};
|
|
16
|
+
export type KvListPutOptions = {
|
|
17
|
+
/** How many to keep, the highest scores; what falls past it is dropped. {@link MAX_LIST_ENTRIES} at most. */
|
|
18
|
+
keep?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Replace an entry already there only with a score at least as high — a player's best, or the latest of two writes
|
|
21
|
+
* that arrived out of order. Otherwise the one there stays and nothing is written.
|
|
22
|
+
*/
|
|
23
|
+
higherOnly?: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** What a put did: whether the entry went in, and what `keep` dropped to make room. */
|
|
26
|
+
export type KvListPut = {
|
|
27
|
+
stored: boolean;
|
|
28
|
+
dropped: KvListEntry[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The `kv` tasks' own view: values rather than strings, and a TTL that means what a caller expects.
|
|
32
|
+
*
|
|
33
|
+
* Built by `createKvStore` over an {@link ActionKvAdapter}, and then narrowed to one space by `namespaceKv`. A
|
|
34
|
+
* task never sees an adapter.
|
|
35
|
+
*/
|
|
36
|
+
export type ActionKvStore = {
|
|
37
|
+
get: (key: string) => Promise<unknown>;
|
|
38
|
+
set: (key: string, value: unknown, ttlSeconds?: number) => Promise<void>;
|
|
39
|
+
delete: (key: string) => Promise<void>;
|
|
40
|
+
increment: (key: string, amount: number, ttlSeconds?: number) => Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Writes `next` only if the key still holds `expected` — the value `get` answered — or, with `expected` undefined,
|
|
43
|
+
* only if it holds nothing. Answers whether it wrote: read, change, and write back with this, and a writer that
|
|
44
|
+
* lost the race is told so instead of undoing the other.
|
|
45
|
+
*/
|
|
46
|
+
swap: (key: string, expected: unknown, next: unknown, ttlSeconds?: number) => Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Puts `entry` in the list — replacing the one with its id — keeping the highest `keep` by score, and answers what
|
|
49
|
+
* that dropped, for whatever it named to be let go of too. A list has no lifetime: it lives until its entries are
|
|
50
|
+
* removed.
|
|
51
|
+
*/
|
|
52
|
+
listPut: (list: string, entry: KvListEntry, options?: KvListPutOptions) => Promise<KvListPut>;
|
|
53
|
+
listRange: (list: string, range?: KvListRange) => Promise<KvListEntry[]>;
|
|
54
|
+
/** Takes the entry with `id` out of the list, and answers whether it was there. */
|
|
55
|
+
listRemove: (list: string, id: string) => Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Writes the list's entry `id` as `next` — or takes it out, `next` null — only if it is still `expected`, the entry
|
|
58
|
+
* `listRange` answered (or, `expected` undefined, only if there is none). Answers whether it wrote: `swap`, for one
|
|
59
|
+
* entry of a list.
|
|
60
|
+
*/
|
|
61
|
+
listSwap: (list: string, id: string, expected: KvListEntry | undefined, next: KvListEntry | null) => Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Reads the list's entry `id`, hands it to `change` and writes back what that answers — `{ score, value }`, or `null`
|
|
64
|
+
* to take it out — reading and asking again when somebody wrote in between. `undefined` writes nothing. A vote that
|
|
65
|
+
* re-scores an entry while the track it is starts was the race (a run's queue): the entry gone, nothing is put back.
|
|
66
|
+
*/
|
|
67
|
+
listChange: (list: string, id: string, change: (current: KvListEntry | undefined) => {
|
|
68
|
+
score: number;
|
|
69
|
+
value: unknown;
|
|
70
|
+
} | null | undefined | Promise<{
|
|
71
|
+
score: number;
|
|
72
|
+
value: unknown;
|
|
73
|
+
} | null | undefined>) => Promise<KvListEntry | null | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Reads the key, hands its value to `change` and writes back what that answers — reading and asking again when
|
|
76
|
+
* somebody wrote in between, so no writer undoes another. `change` answering `undefined` writes nothing. Answers what
|
|
77
|
+
* was written. `lifetime` is seconds, or worked out from the value written.
|
|
78
|
+
*/
|
|
79
|
+
change: <T>(key: string, change: (current: unknown) => T | undefined | Promise<T | undefined>, lifetime?: KvChangeLifetime<T>) => Promise<T | undefined>;
|
|
80
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** What a change needs of a store: read a key, and write it only if it still holds what was read. */
|
|
2
|
+
export type KvChangeStore<V> = {
|
|
3
|
+
get: (key: string) => Promise<V | undefined>;
|
|
4
|
+
swap: (key: string, expected: V | undefined, next: V, ttlSeconds?: number) => Promise<boolean>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The lifetime a change writes with: a number of seconds, one worked out from the value written, or none.
|
|
8
|
+
*/
|
|
9
|
+
export type KvChangeLifetime<T> = number | ((next: T) => number | undefined);
|
|
10
|
+
export type KvChangeOptions<T> = {
|
|
11
|
+
lifetime?: KvChangeLifetime<T> | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The error a change that kept losing ends with — an `ActionRefusal` where there is one to make: being too busy is
|
|
14
|
+
* something to tell whoever asked, not a fault. Handed in because this function may import nothing.
|
|
15
|
+
*/
|
|
16
|
+
refusal: (message: string) => Error;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Reads `key`, hands its value to `change`, and writes back what that answers — unless somebody wrote in between, and
|
|
20
|
+
* then it reads again and asks again. `change` answering `undefined` writes nothing. Answers what was written, or
|
|
21
|
+
* `undefined` when nothing was. Losing every time ends in `refusal`, whose message names no key: it is for a visitor.
|
|
22
|
+
*
|
|
23
|
+
* The one read-change-write there is: `ctx.kv.change`, a list's writes, and the sandbox's `ctx.kv.change` too — its
|
|
24
|
+
* guest is handed THIS function's source (`isolate.ts`), so it must stay self-contained: no import, nothing of this
|
|
25
|
+
* module's, only what the guest's globals also have (`setTimeout`, `Math`).
|
|
26
|
+
*/
|
|
27
|
+
export declare const changeKv: <V, T extends V>(store: KvChangeStore<V>, key: string, change: (current: V | undefined) => T | undefined | Promise<T | undefined>, { lifetime, refusal }: KvChangeOptions<T>) => Promise<T | undefined>;
|
|
28
|
+
/** What a change of a list's entry needs of a store: read the list, and write one entry only if it is still as read. */
|
|
29
|
+
export type KvListChangeStore = {
|
|
30
|
+
listRange: (list: string) => Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
score: number;
|
|
33
|
+
value: unknown;
|
|
34
|
+
}[]>;
|
|
35
|
+
listSwap: (list: string, id: string, expected: {
|
|
36
|
+
id: string;
|
|
37
|
+
score: number;
|
|
38
|
+
value: unknown;
|
|
39
|
+
} | undefined, next: {
|
|
40
|
+
id: string;
|
|
41
|
+
score: number;
|
|
42
|
+
value: unknown;
|
|
43
|
+
} | null) => Promise<boolean>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Reads the list's entry `id`, hands it to `change`, and writes back what that answers (`null` takes it out) — unless
|
|
47
|
+
* somebody wrote it in between, and then it reads again and asks again. `undefined` writes nothing. Answers the entry
|
|
48
|
+
* written, `null` when it was taken out, `undefined` when nothing was written. Self-contained, as `changeKv` is: the
|
|
49
|
+
* sandbox's guest is handed this function's source.
|
|
50
|
+
*/
|
|
51
|
+
export declare const changeListEntry: (store: KvListChangeStore, list: string, id: string, change: (current: {
|
|
52
|
+
id: string;
|
|
53
|
+
score: number;
|
|
54
|
+
value: unknown;
|
|
55
|
+
} | undefined) => {
|
|
56
|
+
score: number;
|
|
57
|
+
value: unknown;
|
|
58
|
+
} | null | undefined | Promise<{
|
|
59
|
+
score: number;
|
|
60
|
+
value: unknown;
|
|
61
|
+
} | null | undefined>, { refusal }: {
|
|
62
|
+
refusal: (message: string) => Error;
|
|
63
|
+
}) => Promise<{
|
|
64
|
+
id: string;
|
|
65
|
+
score: number;
|
|
66
|
+
value: unknown;
|
|
67
|
+
} | null | undefined>;
|