@signstack/cli 0.1.1
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/README.md +458 -0
- package/bin/run.js +12 -0
- package/dist/apps/signstack-cli/schemas/asset.schema.json +220 -0
- package/dist/apps/signstack-cli/schemas/blueprint.schema.json +485 -0
- package/dist/apps/signstack-cli/schemas/jsonata-function.schema.json +185 -0
- package/dist/apps/signstack-cli/schemas/schema.schema.json +97 -0
- package/dist/apps/signstack-cli/schemas/template.schema.json +295 -0
- package/dist/apps/signstack-cli/src/commands/auth/login.d.ts +25 -0
- package/dist/apps/signstack-cli/src/commands/auth/login.js +229 -0
- package/dist/apps/signstack-cli/src/commands/auth/login.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/auth/logout.d.ts +10 -0
- package/dist/apps/signstack-cli/src/commands/auth/logout.js +59 -0
- package/dist/apps/signstack-cli/src/commands/auth/logout.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/auth/whoami.d.ts +9 -0
- package/dist/apps/signstack-cli/src/commands/auth/whoami.js +85 -0
- package/dist/apps/signstack-cli/src/commands/auth/whoami.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/generate.d.ts +51 -0
- package/dist/apps/signstack-cli/src/commands/generate.js +479 -0
- package/dist/apps/signstack-cli/src/commands/generate.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/preview.d.ts +24 -0
- package/dist/apps/signstack-cli/src/commands/preview.js +162 -0
- package/dist/apps/signstack-cli/src/commands/preview.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/pull.d.ts +28 -0
- package/dist/apps/signstack-cli/src/commands/pull.js +244 -0
- package/dist/apps/signstack-cli/src/commands/pull.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/push.d.ts +46 -0
- package/dist/apps/signstack-cli/src/commands/push.js +460 -0
- package/dist/apps/signstack-cli/src/commands/push.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/run.d.ts +22 -0
- package/dist/apps/signstack-cli/src/commands/run.js +126 -0
- package/dist/apps/signstack-cli/src/commands/run.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/test.d.ts +6 -0
- package/dist/apps/signstack-cli/src/commands/test.js +25 -0
- package/dist/apps/signstack-cli/src/commands/test.js.map +1 -0
- package/dist/apps/signstack-cli/src/commands/validate.d.ts +59 -0
- package/dist/apps/signstack-cli/src/commands/validate.js +558 -0
- package/dist/apps/signstack-cli/src/commands/validate.js.map +1 -0
- package/dist/apps/signstack-cli/src/index.d.ts +1 -0
- package/dist/apps/signstack-cli/src/index.js +2 -0
- package/dist/apps/signstack-cli/src/index.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/api-client.d.ts +77 -0
- package/dist/apps/signstack-cli/src/lib/api-client.js +269 -0
- package/dist/apps/signstack-cli/src/lib/api-client.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/base-command.d.ts +38 -0
- package/dist/apps/signstack-cli/src/lib/base-command.js +135 -0
- package/dist/apps/signstack-cli/src/lib/base-command.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/config.d.ts +47 -0
- package/dist/apps/signstack-cli/src/lib/config.js +106 -0
- package/dist/apps/signstack-cli/src/lib/config.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/entity-data-resolver.d.ts +31 -0
- package/dist/apps/signstack-cli/src/lib/entity-data-resolver.js +107 -0
- package/dist/apps/signstack-cli/src/lib/entity-data-resolver.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/local-resource-loader.d.ts +72 -0
- package/dist/apps/signstack-cli/src/lib/local-resource-loader.js +238 -0
- package/dist/apps/signstack-cli/src/lib/local-resource-loader.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/path-utils.d.ts +4 -0
- package/dist/apps/signstack-cli/src/lib/path-utils.js +7 -0
- package/dist/apps/signstack-cli/src/lib/path-utils.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/payload-builder.d.ts +127 -0
- package/dist/apps/signstack-cli/src/lib/payload-builder.js +545 -0
- package/dist/apps/signstack-cli/src/lib/payload-builder.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/preview-handler.d.ts +95 -0
- package/dist/apps/signstack-cli/src/lib/preview-handler.js +611 -0
- package/dist/apps/signstack-cli/src/lib/preview-handler.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/preview-output-formatter.d.ts +63 -0
- package/dist/apps/signstack-cli/src/lib/preview-output-formatter.js +198 -0
- package/dist/apps/signstack-cli/src/lib/preview-output-formatter.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/public-api-client.d.ts +13 -0
- package/dist/apps/signstack-cli/src/lib/public-api-client.js +39 -0
- package/dist/apps/signstack-cli/src/lib/public-api-client.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-puller.d.ts +131 -0
- package/dist/apps/signstack-cli/src/lib/resource-puller.js +800 -0
- package/dist/apps/signstack-cli/src/lib/resource-puller.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-pusher.d.ts +87 -0
- package/dist/apps/signstack-cli/src/lib/resource-pusher.js +361 -0
- package/dist/apps/signstack-cli/src/lib/resource-pusher.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-scanner.d.ts +29 -0
- package/dist/apps/signstack-cli/src/lib/resource-scanner.js +101 -0
- package/dist/apps/signstack-cli/src/lib/resource-scanner.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/resource-validator.d.ts +44 -0
- package/dist/apps/signstack-cli/src/lib/resource-validator.js +158 -0
- package/dist/apps/signstack-cli/src/lib/resource-validator.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/run-handler.d.ts +47 -0
- package/dist/apps/signstack-cli/src/lib/run-handler.js +266 -0
- package/dist/apps/signstack-cli/src/lib/run-handler.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/safe-path.d.ts +28 -0
- package/dist/apps/signstack-cli/src/lib/safe-path.js +44 -0
- package/dist/apps/signstack-cli/src/lib/safe-path.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/scenario-file.d.ts +35 -0
- package/dist/apps/signstack-cli/src/lib/scenario-file.js +80 -0
- package/dist/apps/signstack-cli/src/lib/scenario-file.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/schema-validator.d.ts +8 -0
- package/dist/apps/signstack-cli/src/lib/schema-validator.js +39 -0
- package/dist/apps/signstack-cli/src/lib/schema-validator.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/url-validator.d.ts +17 -0
- package/dist/apps/signstack-cli/src/lib/url-validator.js +61 -0
- package/dist/apps/signstack-cli/src/lib/url-validator.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/yaml-document-parser.d.ts +25 -0
- package/dist/apps/signstack-cli/src/lib/yaml-document-parser.js +133 -0
- package/dist/apps/signstack-cli/src/lib/yaml-document-parser.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/yaml-transforms.d.ts +3 -0
- package/dist/apps/signstack-cli/src/lib/yaml-transforms.js +32 -0
- package/dist/apps/signstack-cli/src/lib/yaml-transforms.js.map +1 -0
- package/dist/apps/signstack-cli/src/lib/yaml-writer.d.ts +47 -0
- package/dist/apps/signstack-cli/src/lib/yaml-writer.js +160 -0
- package/dist/apps/signstack-cli/src/lib/yaml-writer.js.map +1 -0
- package/dist/apps/signstack-cli/src/types/auth.types.d.ts +48 -0
- package/dist/apps/signstack-cli/src/types/auth.types.js +31 -0
- package/dist/apps/signstack-cli/src/types/auth.types.js.map +1 -0
- package/dist/apps/signstack-cli/src/types/schema.types.d.ts +14 -0
- package/dist/apps/signstack-cli/src/types/schema.types.js +16 -0
- package/dist/apps/signstack-cli/src/types/schema.types.js.map +1 -0
- package/dist/apps/signstack-cli/src/types/yaml.types.d.ts +144 -0
- package/dist/apps/signstack-cli/src/types/yaml.types.js +2 -0
- package/dist/apps/signstack-cli/src/types/yaml.types.js.map +1 -0
- package/dist/libs/common/base/src/index.d.ts +14 -0
- package/dist/libs/common/base/src/index.js +44 -0
- package/dist/libs/common/base/src/index.js.map +1 -0
- package/dist/libs/common/base/src/lib/address.util.d.ts +12 -0
- package/dist/libs/common/base/src/lib/address.util.js +55 -0
- package/dist/libs/common/base/src/lib/address.util.js.map +1 -0
- package/dist/libs/common/base/src/lib/country-code-data.d.ts +5 -0
- package/dist/libs/common/base/src/lib/country-code-data.js +1256 -0
- package/dist/libs/common/base/src/lib/country-code-data.js.map +1 -0
- package/dist/libs/common/base/src/lib/date.util.d.ts +13 -0
- package/dist/libs/common/base/src/lib/date.util.js +135 -0
- package/dist/libs/common/base/src/lib/date.util.js.map +1 -0
- package/dist/libs/common/base/src/lib/headers.d.ts +1 -0
- package/dist/libs/common/base/src/lib/headers.js +5 -0
- package/dist/libs/common/base/src/lib/headers.js.map +1 -0
- package/dist/libs/common/base/src/lib/jsonata.service.d.ts +32 -0
- package/dist/libs/common/base/src/lib/jsonata.service.js +207 -0
- package/dist/libs/common/base/src/lib/jsonata.service.js.map +1 -0
- package/dist/libs/common/base/src/lib/key-validation.constants.d.ts +37 -0
- package/dist/libs/common/base/src/lib/key-validation.constants.js +144 -0
- package/dist/libs/common/base/src/lib/key-validation.constants.js.map +1 -0
- package/dist/libs/common/base/src/lib/phone-util.d.ts +16 -0
- package/dist/libs/common/base/src/lib/phone-util.js +61 -0
- package/dist/libs/common/base/src/lib/phone-util.js.map +1 -0
- package/dist/libs/common/base/src/lib/schema-validation.util.d.ts +24 -0
- package/dist/libs/common/base/src/lib/schema-validation.util.js +155 -0
- package/dist/libs/common/base/src/lib/schema-validation.util.js.map +1 -0
- package/dist/libs/common/base/src/lib/string-builder.d.ts +48 -0
- package/dist/libs/common/base/src/lib/string-builder.js +90 -0
- package/dist/libs/common/base/src/lib/string-builder.js.map +1 -0
- package/dist/libs/common/base/src/lib/util.d.ts +20 -0
- package/dist/libs/common/base/src/lib/util.js +110 -0
- package/dist/libs/common/base/src/lib/util.js.map +1 -0
- package/dist/libs/signstack/base/schemas/asset.schema.json +220 -0
- package/dist/libs/signstack/base/schemas/blueprint.schema.json +485 -0
- package/dist/libs/signstack/base/schemas/jsonata-function.schema.json +185 -0
- package/dist/libs/signstack/base/schemas/schema.schema.json +97 -0
- package/dist/libs/signstack/base/schemas/template.schema.json +295 -0
- package/dist/libs/signstack/base/src/index.d.ts +28 -0
- package/dist/libs/signstack/base/src/index.js +32 -0
- package/dist/libs/signstack/base/src/index.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/constants.d.ts +123 -0
- package/dist/libs/signstack/base/src/lib/constants.js +131 -0
- package/dist/libs/signstack/base/src/lib/constants.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/hash.util.d.ts +58 -0
- package/dist/libs/signstack/base/src/lib/hash.util.js +90 -0
- package/dist/libs/signstack/base/src/lib/hash.util.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/is-schema-renderable.util.d.ts +29 -0
- package/dist/libs/signstack/base/src/lib/is-schema-renderable.util.js +93 -0
- package/dist/libs/signstack/base/src/lib/is-schema-renderable.util.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/ai-chat.d.ts +41 -0
- package/dist/libs/signstack/base/src/lib/models/ai-chat.js +3 -0
- package/dist/libs/signstack/base/src/lib/models/ai-chat.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/api-key.d.ts +54 -0
- package/dist/libs/signstack/base/src/lib/models/api-key.js +18 -0
- package/dist/libs/signstack/base/src/lib/models/api-key.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/asset.d.ts +101 -0
- package/dist/libs/signstack/base/src/lib/models/asset.js +11 -0
- package/dist/libs/signstack/base/src/lib/models/asset.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/auth.d.ts +142 -0
- package/dist/libs/signstack/base/src/lib/models/auth.js +35 -0
- package/dist/libs/signstack/base/src/lib/models/auth.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/base.d.ts +134 -0
- package/dist/libs/signstack/base/src/lib/models/base.js +71 -0
- package/dist/libs/signstack/base/src/lib/models/base.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/blueprint.d.ts +311 -0
- package/dist/libs/signstack/base/src/lib/models/blueprint.js +9 -0
- package/dist/libs/signstack/base/src/lib/models/blueprint.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/file.d.ts +75 -0
- package/dist/libs/signstack/base/src/lib/models/file.js +9 -0
- package/dist/libs/signstack/base/src/lib/models/file.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/jsonata-function.d.ts +111 -0
- package/dist/libs/signstack/base/src/lib/models/jsonata-function.js +19 -0
- package/dist/libs/signstack/base/src/lib/models/jsonata-function.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/marketplace-listing.d.ts +132 -0
- package/dist/libs/signstack/base/src/lib/models/marketplace-listing.js +22 -0
- package/dist/libs/signstack/base/src/lib/models/marketplace-listing.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/membership.d.ts +127 -0
- package/dist/libs/signstack/base/src/lib/models/membership.js +22 -0
- package/dist/libs/signstack/base/src/lib/models/membership.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/namespace.d.ts +87 -0
- package/dist/libs/signstack/base/src/lib/models/namespace.js +57 -0
- package/dist/libs/signstack/base/src/lib/models/namespace.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/organization.d.ts +79 -0
- package/dist/libs/signstack/base/src/lib/models/organization.js +41 -0
- package/dist/libs/signstack/base/src/lib/models/organization.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/render-job.d.ts +88 -0
- package/dist/libs/signstack/base/src/lib/models/render-job.js +3 -0
- package/dist/libs/signstack/base/src/lib/models/render-job.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/resource-edge.d.ts +60 -0
- package/dist/libs/signstack/base/src/lib/models/resource-edge.js +202 -0
- package/dist/libs/signstack/base/src/lib/models/resource-edge.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/scenario.d.ts +138 -0
- package/dist/libs/signstack/base/src/lib/models/scenario.js +14 -0
- package/dist/libs/signstack/base/src/lib/models/scenario.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/schema.d.ts +131 -0
- package/dist/libs/signstack/base/src/lib/models/schema.js +44 -0
- package/dist/libs/signstack/base/src/lib/models/schema.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/shareable-link.d.ts +215 -0
- package/dist/libs/signstack/base/src/lib/models/shareable-link.js +27 -0
- package/dist/libs/signstack/base/src/lib/models/shareable-link.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/subscription.d.ts +279 -0
- package/dist/libs/signstack/base/src/lib/models/subscription.js +105 -0
- package/dist/libs/signstack/base/src/lib/models/subscription.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/template.d.ts +248 -0
- package/dist/libs/signstack/base/src/lib/models/template.js +32 -0
- package/dist/libs/signstack/base/src/lib/models/template.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/user.d.ts +30 -0
- package/dist/libs/signstack/base/src/lib/models/user.js +3 -0
- package/dist/libs/signstack/base/src/lib/models/user.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/webhook.d.ts +223 -0
- package/dist/libs/signstack/base/src/lib/models/webhook.js +62 -0
- package/dist/libs/signstack/base/src/lib/models/webhook.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/models/workflow.d.ts +917 -0
- package/dist/libs/signstack/base/src/lib/models/workflow.js +152 -0
- package/dist/libs/signstack/base/src/lib/models/workflow.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/util.d.ts +92 -0
- package/dist/libs/signstack/base/src/lib/util.js +406 -0
- package/dist/libs/signstack/base/src/lib/util.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/dependency-graph.d.ts +94 -0
- package/dist/libs/signstack/base/src/lib/validation/dependency-graph.js +446 -0
- package/dist/libs/signstack/base/src/lib/validation/dependency-graph.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/graph.types.d.ts +57 -0
- package/dist/libs/signstack/base/src/lib/validation/graph.types.js +8 -0
- package/dist/libs/signstack/base/src/lib/validation/graph.types.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/index.d.ts +9 -0
- package/dist/libs/signstack/base/src/lib/validation/index.js +23 -0
- package/dist/libs/signstack/base/src/lib/validation/index.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/resource-schemas.d.ts +3 -0
- package/dist/libs/signstack/base/src/lib/validation/resource-schemas.js +27 -0
- package/dist/libs/signstack/base/src/lib/validation/resource-schemas.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validation.types.d.ts +57 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validation.types.js +57 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validation.types.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validator.d.ts +38 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validator.js +146 -0
- package/dist/libs/signstack/base/src/lib/validation/schema-validator.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-dependencies.d.ts +22 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-dependencies.js +69 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-dependencies.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-resource-tree.d.ts +37 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-resource-tree.js +250 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-resource-tree.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-template-inputs.d.ts +24 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-template-inputs.js +98 -0
- package/dist/libs/signstack/base/src/lib/validation/validate-template-inputs.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/validation/yaml-document-utils.d.ts +12 -0
- package/dist/libs/signstack/base/src/lib/validation/yaml-document-utils.js +50 -0
- package/dist/libs/signstack/base/src/lib/validation/yaml-document-utils.js.map +1 -0
- package/dist/libs/signstack/base/src/lib/yaml-spec-converter.d.ts +101 -0
- package/dist/libs/signstack/base/src/lib/yaml-spec-converter.js +998 -0
- package/dist/libs/signstack/base/src/lib/yaml-spec-converter.js.map +1 -0
- package/oclif.manifest.json +822 -0
- package/package.json +101 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { ListResp } from './base';
|
|
2
|
+
/**
|
|
3
|
+
* Shareable links for published blueprints (Task 91).
|
|
4
|
+
*
|
|
5
|
+
* A namespace user mints a public, unguessable URL that opens a branded,
|
|
6
|
+
* anonymous form. The customer fills only the fields they know; the creator
|
|
7
|
+
* has hardcoded the rest (e.g. Company Address, Company Tax Id), which render
|
|
8
|
+
* pre-filled and read-only. On submit, a workflow is created from the published
|
|
9
|
+
* blueprint and the customer is dropped into the existing signing experience.
|
|
10
|
+
*
|
|
11
|
+
* See `sharable-blueprint-plan.md` for the full design.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Per-namespace cap on shareable links. Bounds the storage / enumeration
|
|
15
|
+
* surface of a publicly-reachable resource. Enforced at create time; Studio
|
|
16
|
+
* uses it to disable the "Create link" button at the cap. Mirrors
|
|
17
|
+
* `MAX_WEBHOOKS_PER_NAMESPACE`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MAX_SHAREABLE_LINKS_PER_NAMESPACE = 50;
|
|
20
|
+
export declare enum ShareableLinkSourceType {
|
|
21
|
+
Blueprint = "blueprint",
|
|
22
|
+
Listing = "listing"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Source the link targets — a same-namespace blueprint OR a marketplace listing,
|
|
26
|
+
* told apart by `type`. `key`/`version` apply to both (the blueprint's or the
|
|
27
|
+
* listing's), mirroring the blueprint|listing split used by workflow creation.
|
|
28
|
+
*/
|
|
29
|
+
export interface ShareableLinkSource {
|
|
30
|
+
type: ShareableLinkSourceType;
|
|
31
|
+
key: string;
|
|
32
|
+
version: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CreateShareableLinkReq {
|
|
35
|
+
source: ShareableLinkSource;
|
|
36
|
+
/**
|
|
37
|
+
* inputKey -> hardcoded value. Same shape as `CreateWorkflowReq.data`: usually
|
|
38
|
+
* a (full or partial) data object, but a top-level scalar input maps to a bare
|
|
39
|
+
* scalar. Every field present is rendered read-only on the public form — the
|
|
40
|
+
* customer can only fill the fields left blank.
|
|
41
|
+
*/
|
|
42
|
+
prefill?: Record<string, any>;
|
|
43
|
+
/** Required. Shown as the heading on the public form (and in the creator's list). */
|
|
44
|
+
title: string;
|
|
45
|
+
/** Optional blurb shown under the title on the public page. May be multi-line. */
|
|
46
|
+
description?: string;
|
|
47
|
+
/** ISO date string; omit for "never expires". */
|
|
48
|
+
expiresAt?: string;
|
|
49
|
+
/** Hard ceiling on total submissions; omit for unlimited. */
|
|
50
|
+
maxSubmissions?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Body of `POST /shareable-links/generate-metadata` — asks the AI to draft a
|
|
54
|
+
* customer-facing title + description for a link from its source blueprint.
|
|
55
|
+
*/
|
|
56
|
+
export interface GenerateShareableLinkMetadataReq {
|
|
57
|
+
source: ShareableLinkSource;
|
|
58
|
+
}
|
|
59
|
+
export interface GenerateShareableLinkMetadataResp {
|
|
60
|
+
/** Suggested heading for the public form. May be empty if generation failed. */
|
|
61
|
+
title: string;
|
|
62
|
+
/** Suggested blurb under the title. May be empty. */
|
|
63
|
+
description: string;
|
|
64
|
+
}
|
|
65
|
+
export interface UpdateShareableLinkReq {
|
|
66
|
+
/** inputKey -> hardcoded value (object, or a bare scalar for scalar inputs). */
|
|
67
|
+
prefill?: Record<string, any>;
|
|
68
|
+
/** Required title. Omit to leave unchanged; cannot be blanked. */
|
|
69
|
+
title?: string;
|
|
70
|
+
/** Public description. Send '' to clear; omit to leave unchanged. */
|
|
71
|
+
description?: string;
|
|
72
|
+
/** Kill-switch. `false` => public resolve/submit return 410. */
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
/** `null` clears the expiry. */
|
|
75
|
+
expiresAt?: string | null;
|
|
76
|
+
/** `null` clears the cap. */
|
|
77
|
+
maxSubmissions?: number | null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Full shareable link — returned by the authenticated management endpoints.
|
|
81
|
+
* The optimistic-locking handle is on the `ETag` HTTP response header — pass it
|
|
82
|
+
* back as `If-Match` on the next `PATCH` / `DELETE`.
|
|
83
|
+
*/
|
|
84
|
+
export interface ShareableLinkResp {
|
|
85
|
+
/** Prefixed lowercase ULID, e.g. `sl_01jv8m7qfj6xj9gkz7a4s2h8e`. This IS the public URL token. */
|
|
86
|
+
id: string;
|
|
87
|
+
/** Absolute public URL incl. scheme, built server-side from the request host. */
|
|
88
|
+
url: string;
|
|
89
|
+
source: ShareableLinkSource;
|
|
90
|
+
/** inputKey -> hardcoded value (object, or a bare scalar for scalar inputs). */
|
|
91
|
+
prefill: Record<string, any>;
|
|
92
|
+
/** Required. Heading shown on the public form and in the creator's list. */
|
|
93
|
+
title: string;
|
|
94
|
+
/** Optional, possibly multi-line, shown under the title on the public page. */
|
|
95
|
+
description?: string;
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
expiresAt?: string;
|
|
98
|
+
maxSubmissions?: number;
|
|
99
|
+
submissionCount: number;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* List item — carries `_eTag` per item since list responses cannot multiplex
|
|
105
|
+
* the single-valued `ETag` header. Pass back as `If-Match` on a subsequent
|
|
106
|
+
* `PATCH` / `DELETE`.
|
|
107
|
+
*/
|
|
108
|
+
export interface ShareableLinkListItem extends ShareableLinkResp {
|
|
109
|
+
_eTag: string;
|
|
110
|
+
}
|
|
111
|
+
export type ListShareableLinksResp = ListResp<ShareableLinkListItem>;
|
|
112
|
+
/**
|
|
113
|
+
* Minimal namespace brand for the public page. Deliberately excludes
|
|
114
|
+
* `contactEmail`, `senderEmail*`, `phone`, `address`, `logoFileId`, `mode`,
|
|
115
|
+
* timestamps, ids — anything that is PII or internal config. See plan §7.7.
|
|
116
|
+
*/
|
|
117
|
+
export interface PublicNamespaceBrand {
|
|
118
|
+
/** company ?? senderName ?? org equivalents ?? platform default. */
|
|
119
|
+
name: string;
|
|
120
|
+
/** First https logo URL up the namespace→org chain ?? platform default. Never `gs://`. */
|
|
121
|
+
logoUrl: string;
|
|
122
|
+
}
|
|
123
|
+
/** Render-only projection of a JSON Schema property (no internal descriptions/expressions). */
|
|
124
|
+
export interface PublicSchemaProperty {
|
|
125
|
+
type: string;
|
|
126
|
+
title?: string;
|
|
127
|
+
format?: string;
|
|
128
|
+
enum?: Array<string | number>;
|
|
129
|
+
/** Nested objects are supported. */
|
|
130
|
+
properties?: Record<string, PublicSchemaProperty>;
|
|
131
|
+
/** For object properties: the keys of its required children (drives required validation). */
|
|
132
|
+
required?: string[];
|
|
133
|
+
/** For array properties: the per-item schema (drives the `ss-repeat` rows). */
|
|
134
|
+
items?: PublicSchemaProperty;
|
|
135
|
+
/** Number: inclusive minimum / maximum. */
|
|
136
|
+
minimum?: number;
|
|
137
|
+
maximum?: number;
|
|
138
|
+
/** Number: exclusive minimum / maximum. */
|
|
139
|
+
exclusiveMinimum?: number;
|
|
140
|
+
exclusiveMaximum?: number;
|
|
141
|
+
/** Number: value must be a multiple of this (also sets the input step). */
|
|
142
|
+
multipleOf?: number;
|
|
143
|
+
/** String: min / max length. */
|
|
144
|
+
minLength?: number;
|
|
145
|
+
maxLength?: number;
|
|
146
|
+
/** String: regex the value must match. */
|
|
147
|
+
pattern?: string;
|
|
148
|
+
/** Array: min / max number of items. */
|
|
149
|
+
minItems?: number;
|
|
150
|
+
maxItems?: number;
|
|
151
|
+
}
|
|
152
|
+
/** Object-input projection: the common case (kept for clarity / back-compat). */
|
|
153
|
+
export interface PublicInputSchema {
|
|
154
|
+
type: 'object';
|
|
155
|
+
title?: string;
|
|
156
|
+
required?: string[];
|
|
157
|
+
properties: Record<string, PublicSchemaProperty>;
|
|
158
|
+
}
|
|
159
|
+
export interface PublicShareableLinkInput {
|
|
160
|
+
/** Blueprint `Input.key`. */
|
|
161
|
+
key: string;
|
|
162
|
+
name?: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
/** Pre-evaluated literal — expression-required is resolved server-side. */
|
|
165
|
+
required: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Render-only schema projection (NOT the raw `schemaDefinition`). Usually an
|
|
168
|
+
* object (`PublicInputSchema`), but a top-level **scalar** input projects to a
|
|
169
|
+
* bare `PublicSchemaProperty` (e.g. `{ type: 'string', format: 'email' }`) and
|
|
170
|
+
* renders as a single field.
|
|
171
|
+
*/
|
|
172
|
+
schema: PublicSchemaProperty;
|
|
173
|
+
}
|
|
174
|
+
/** Response of the public `GET /shareable-links/:id` resolve endpoint. */
|
|
175
|
+
export interface ResolveShareableLinkResp {
|
|
176
|
+
brand: PublicNamespaceBrand;
|
|
177
|
+
/** The link's title — the heading shown on the public form. */
|
|
178
|
+
title: string;
|
|
179
|
+
/** Optional, possibly multi-line description shown under the title. */
|
|
180
|
+
description?: string;
|
|
181
|
+
inputs: PublicShareableLinkInput[];
|
|
182
|
+
/**
|
|
183
|
+
* inputKey -> hardcoded value (object, or a bare scalar for scalar inputs).
|
|
184
|
+
* Every field present is pre-filled and rendered read-only on the public form;
|
|
185
|
+
* the customer fills only the rest.
|
|
186
|
+
*/
|
|
187
|
+
prefill: Record<string, any>;
|
|
188
|
+
}
|
|
189
|
+
/** Body of the public `POST /shareable-links/:id/submit` endpoint. */
|
|
190
|
+
export interface SubmitShareableLinkReq {
|
|
191
|
+
/**
|
|
192
|
+
* User-entered value per inputKey (an object, or a bare scalar for scalar
|
|
193
|
+
* inputs). Hardcoded fields are re-applied server-side, so anything sent for
|
|
194
|
+
* them is ignored. Each participant's name and email are carried by these
|
|
195
|
+
* inputs (the blueprint maps them via its `participant.name`/`email`
|
|
196
|
+
* expressions) — the public form never collects participant identity separately.
|
|
197
|
+
*/
|
|
198
|
+
data: Record<string, any>;
|
|
199
|
+
/** Client-generated per attempt — a double-click guard, NOT a rate limit. */
|
|
200
|
+
idempotencyKey: string;
|
|
201
|
+
}
|
|
202
|
+
export interface SubmitShareableLinkResp {
|
|
203
|
+
/**
|
|
204
|
+
* Whether the workflow has any signing step. `true` => the workflow has
|
|
205
|
+
* emailed a signing link to each participant at the address carried in the
|
|
206
|
+
* submitted inputs (they sign from the email — never in-browser, since a
|
|
207
|
+
* public link can't prove email ownership). `false` => the blueprint is
|
|
208
|
+
* form/automation-only (or `includeIf` pruned every step), so the submission
|
|
209
|
+
* is already complete with nothing to sign.
|
|
210
|
+
*
|
|
211
|
+
* Signing tokens are deliberately NOT returned: exposing one would let the
|
|
212
|
+
* submitter sign without opening the email, bypassing the ownership check.
|
|
213
|
+
*/
|
|
214
|
+
requiresSigning: boolean;
|
|
215
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShareableLinkSourceType = exports.MAX_SHAREABLE_LINKS_PER_NAMESPACE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Shareable links for published blueprints (Task 91).
|
|
6
|
+
*
|
|
7
|
+
* A namespace user mints a public, unguessable URL that opens a branded,
|
|
8
|
+
* anonymous form. The customer fills only the fields they know; the creator
|
|
9
|
+
* has hardcoded the rest (e.g. Company Address, Company Tax Id), which render
|
|
10
|
+
* pre-filled and read-only. On submit, a workflow is created from the published
|
|
11
|
+
* blueprint and the customer is dropped into the existing signing experience.
|
|
12
|
+
*
|
|
13
|
+
* See `sharable-blueprint-plan.md` for the full design.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Per-namespace cap on shareable links. Bounds the storage / enumeration
|
|
17
|
+
* surface of a publicly-reachable resource. Enforced at create time; Studio
|
|
18
|
+
* uses it to disable the "Create link" button at the cap. Mirrors
|
|
19
|
+
* `MAX_WEBHOOKS_PER_NAMESPACE`.
|
|
20
|
+
*/
|
|
21
|
+
exports.MAX_SHAREABLE_LINKS_PER_NAMESPACE = 50;
|
|
22
|
+
var ShareableLinkSourceType;
|
|
23
|
+
(function (ShareableLinkSourceType) {
|
|
24
|
+
ShareableLinkSourceType["Blueprint"] = "blueprint";
|
|
25
|
+
ShareableLinkSourceType["Listing"] = "listing";
|
|
26
|
+
})(ShareableLinkSourceType || (exports.ShareableLinkSourceType = ShareableLinkSourceType = {}));
|
|
27
|
+
//# sourceMappingURL=shareable-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shareable-link.js","sourceRoot":"","sources":["../../../../../../../../../libs/signstack/base/src/lib/models/shareable-link.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACU,QAAA,iCAAiC,GAAG,EAAE,CAAC;AAEpD,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IACjC,kDAAuB,CAAA;IACvB,8CAAmB,CAAA;AACrB,CAAC,EAHW,uBAAuB,uCAAvB,uBAAuB,QAGlC"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscription / billing shared types.
|
|
3
|
+
*
|
|
4
|
+
* Money is always integer cents — never floats. Currency formatting happens
|
|
5
|
+
* in the FE display layer.
|
|
6
|
+
*
|
|
7
|
+
* IDs:
|
|
8
|
+
* - Internal subscription doc id is prefixed `bsub_…` (billing subscription)
|
|
9
|
+
* to avoid colliding with Stripe's own `sub_…` ids. Stripe's id lives in
|
|
10
|
+
* `stripeSubscriptionId`.
|
|
11
|
+
* - Internal usage-period doc id is prefixed `up_…`.
|
|
12
|
+
* - Internal usage-event doc id is prefixed `ue_…`.
|
|
13
|
+
*/
|
|
14
|
+
export declare enum PlanCode {
|
|
15
|
+
Free = "free",
|
|
16
|
+
Pro = "pro"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 1:1 mirror of Stripe's subscription status enum. **All values are intentional**
|
|
20
|
+
* even though only a subset drives bespoke code paths — the schema's Mongoose
|
|
21
|
+
* `enum` validator rejects writes with unknown values, so every status Stripe
|
|
22
|
+
* may emit must be listed here or the corresponding webhook update crashes
|
|
23
|
+
* mid-write and the local doc drifts.
|
|
24
|
+
*
|
|
25
|
+
* Three categories (see the grouped sections below):
|
|
26
|
+
*
|
|
27
|
+
* 1. **Active states** — `isSubscriptionActive()` returns true; the org can
|
|
28
|
+
* create Live workflows. Includes `past_due` because we honour the grace
|
|
29
|
+
* period before locking access.
|
|
30
|
+
*
|
|
31
|
+
* 2. **Terminal states** — `applySubscriptionUpdate` flips the org back to
|
|
32
|
+
* the Free baseline via `transitionToFree`.
|
|
33
|
+
*
|
|
34
|
+
* 3. **Pass-through states** — accepted by the schema so webhooks don't
|
|
35
|
+
* crash, but no bespoke handler. Stripe is the system of record; if any
|
|
36
|
+
* of these starts mattering to a feature, add the handler then.
|
|
37
|
+
*
|
|
38
|
+
* Reference: https://stripe.com/docs/api/subscriptions/object#subscription_object-status
|
|
39
|
+
*/
|
|
40
|
+
export declare enum SubscriptionStatus {
|
|
41
|
+
Active = "active",
|
|
42
|
+
/** Pro user with a failed payment. Stripe retries on its retry schedule
|
|
43
|
+
* (configured in the Dashboard) and auto-cancels if retries exhaust;
|
|
44
|
+
* we keep access active during this window. */
|
|
45
|
+
PastDue = "past_due",
|
|
46
|
+
/** Reserved — we don't ship trials today, but the access gate already
|
|
47
|
+
* treats this as active so adding trials is purely a Stripe-side change. */
|
|
48
|
+
Trialing = "trialing",
|
|
49
|
+
/** User canceled (immediate or via Customer Portal). */
|
|
50
|
+
Canceled = "canceled",
|
|
51
|
+
/** First-invoice payment never cleared within Stripe's ~23h window. */
|
|
52
|
+
IncompleteExpired = "incomplete_expired",
|
|
53
|
+
/** Initial state for every Stripe-created sub before the first payment
|
|
54
|
+
* attempt resolves — typically flips to `active` within seconds via the
|
|
55
|
+
* follow-up `customer.subscription.updated` event. */
|
|
56
|
+
Incomplete = "incomplete",
|
|
57
|
+
/** Stripe-emitted after retries exhaust mid-cycle. We don't act on this
|
|
58
|
+
* directly — the next `past_due → cancel` cycle (or operator action)
|
|
59
|
+
* resolves the sub. */
|
|
60
|
+
Unpaid = "unpaid",
|
|
61
|
+
/** Customer Portal pause. We don't expose pause as a product feature, so
|
|
62
|
+
* the doc just mirrors Stripe and the org keeps its current access until
|
|
63
|
+
* Stripe transitions it to a real terminal state. */
|
|
64
|
+
Paused = "paused"
|
|
65
|
+
}
|
|
66
|
+
export declare enum UsageBillingCategory {
|
|
67
|
+
/** Counted against the plan's included quota. */
|
|
68
|
+
Included = "included",
|
|
69
|
+
/** Charged as overage via Stripe metered Price. */
|
|
70
|
+
Overage = "overage"
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Plan catalog — one row per offered plan. Mutated only via deploy / admin
|
|
74
|
+
* scripts. Read every request (cached in-memory by `SubscriptionPlanService`).
|
|
75
|
+
*/
|
|
76
|
+
export interface SubscriptionPlan {
|
|
77
|
+
planCode: PlanCode;
|
|
78
|
+
displayName: string;
|
|
79
|
+
description: string;
|
|
80
|
+
isActive: boolean;
|
|
81
|
+
/** Workflows included in the base subscription per billing period. */
|
|
82
|
+
includedWorkflows: number;
|
|
83
|
+
/**
|
|
84
|
+
* Hard-cap for plans without an overage Price (e.g. Free). `null` = no hard
|
|
85
|
+
* cap (Pro relies on overage charges instead of blocking).
|
|
86
|
+
*/
|
|
87
|
+
hardLimitWorkflows: number | null;
|
|
88
|
+
/** Stripe Price ID for the recurring base fee. `null` for Free. */
|
|
89
|
+
stripeBasePriceId: string | null;
|
|
90
|
+
/** Stripe Price ID for the metered overage. `null` if no overage. */
|
|
91
|
+
stripeOveragePriceId: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* Stripe Billing Meter `event_name` that this plan's overage Price is
|
|
94
|
+
* linked to. Required for reporting on Stripe accounts that use the new
|
|
95
|
+
* Billing Meters API (which is the default for accounts created after
|
|
96
|
+
* mid-2024). The reporter POSTs `billing.meterEvents.create({ event_name,
|
|
97
|
+
* payload: { stripe_customer_id, value }, identifier })` against this
|
|
98
|
+
* name. `null` for plans with no overage or for legacy accounts still on
|
|
99
|
+
* the deprecated `subscriptionItems.createUsageRecord` API (we don't ship
|
|
100
|
+
* a code path for the legacy API anymore).
|
|
101
|
+
*/
|
|
102
|
+
stripeOverageMeterEventName: string | null;
|
|
103
|
+
/** Cents per overage unit — display only. Stripe is source of truth for charging. */
|
|
104
|
+
overageUnitAmountCents: number | null;
|
|
105
|
+
/** Cents for base recurring fee — display only. */
|
|
106
|
+
baseAmountCents: number | null;
|
|
107
|
+
currency: string;
|
|
108
|
+
/** Sort order for the pricing page. */
|
|
109
|
+
displayOrder: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Discount currently attached to a subscription (or customer-level, applied to
|
|
113
|
+
* a subscription). Sourced from Stripe's `subscription.discounts[]` snapshot
|
|
114
|
+
* on every `customer.subscription.*` webhook — `undefined` here means no
|
|
115
|
+
* active discount on this subscription right now.
|
|
116
|
+
*
|
|
117
|
+
* Exactly one of `percentOff` / `amountOffCents` is set, mirroring Stripe's
|
|
118
|
+
* `coupon` shape.
|
|
119
|
+
*
|
|
120
|
+
* `label` is FE-ready ("20% off" / "$5.00 off") so the UI doesn't reimplement
|
|
121
|
+
* the formatting.
|
|
122
|
+
*/
|
|
123
|
+
export interface DiscountSummary {
|
|
124
|
+
/** Stripe coupon id (`co_…`). */
|
|
125
|
+
couponId: string;
|
|
126
|
+
/**
|
|
127
|
+
* Customer-facing promo code text (e.g. `LAUNCH20`) when the discount came
|
|
128
|
+
* from a `promotion_code` redemption at Checkout. `undefined` when the
|
|
129
|
+
* coupon was attached directly (Dashboard / API), since direct attachments
|
|
130
|
+
* don't go through a promotion_code.
|
|
131
|
+
*/
|
|
132
|
+
promoCode?: string;
|
|
133
|
+
/** Pre-formatted human label, e.g. "20% off" or "$5.00 off". */
|
|
134
|
+
label: string;
|
|
135
|
+
/** Percent off (1-100). Set when the coupon is percentage-based. */
|
|
136
|
+
percentOff?: number;
|
|
137
|
+
/** Cents off the invoice subtotal. Set when the coupon is amount-based. */
|
|
138
|
+
amountOffCents?: number;
|
|
139
|
+
/** Coupon duration semantics — controls when Stripe auto-removes. */
|
|
140
|
+
duration: 'once' | 'repeating' | 'forever';
|
|
141
|
+
/** Months remaining for `repeating` duration. `undefined` for `once`/`forever`. */
|
|
142
|
+
durationInMonths?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Hard end timestamp from Stripe (set for `once`/`repeating`). `undefined`
|
|
145
|
+
* for `forever` — that one only ends if explicitly removed.
|
|
146
|
+
*/
|
|
147
|
+
endsAt?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Per-org current subscription state — denormalized cache of Stripe state.
|
|
151
|
+
* Stripe webhooks are the only mutator after initial seeding.
|
|
152
|
+
*/
|
|
153
|
+
export interface SubscriptionResp {
|
|
154
|
+
/** Internal id, prefix `bsub_`. */
|
|
155
|
+
id: string;
|
|
156
|
+
orgId: string;
|
|
157
|
+
planCode: PlanCode;
|
|
158
|
+
status: SubscriptionStatus;
|
|
159
|
+
/** UTC period boundaries — for Free, derived from calendar month. */
|
|
160
|
+
currentPeriodStart: string;
|
|
161
|
+
currentPeriodEnd: string;
|
|
162
|
+
/** Set when user clicks "cancel" — resolves at period end. */
|
|
163
|
+
cancelAtPeriodEnd?: boolean;
|
|
164
|
+
canceledAt?: string;
|
|
165
|
+
pastDueSince?: string;
|
|
166
|
+
/** Cached for fast reads — Stripe is authoritative. */
|
|
167
|
+
stripeCustomerId?: string;
|
|
168
|
+
stripeSubscriptionId?: string;
|
|
169
|
+
stripeBasePriceId?: string;
|
|
170
|
+
stripeOveragePriceId?: string;
|
|
171
|
+
/** Cached plan snapshot — useful for FE rendering without a join. */
|
|
172
|
+
plan?: Pick<SubscriptionPlan, 'planCode' | 'displayName' | 'includedWorkflows' | 'hardLimitWorkflows' | 'overageUnitAmountCents' | 'baseAmountCents' | 'currency'>;
|
|
173
|
+
/**
|
|
174
|
+
* Active discount on this subscription — present when the user redeemed a
|
|
175
|
+
* promo code at Checkout, or when a coupon was attached customer-level.
|
|
176
|
+
* `undefined` for full-price subscriptions.
|
|
177
|
+
*/
|
|
178
|
+
discount?: DiscountSummary;
|
|
179
|
+
}
|
|
180
|
+
export interface ListPlansResp {
|
|
181
|
+
data: SubscriptionPlan[];
|
|
182
|
+
}
|
|
183
|
+
export interface UsageResp {
|
|
184
|
+
orgId: string;
|
|
185
|
+
planCode: PlanCode;
|
|
186
|
+
currentPeriodStart: string;
|
|
187
|
+
currentPeriodEnd: string;
|
|
188
|
+
includedQuota: number;
|
|
189
|
+
includedUsed: number;
|
|
190
|
+
overageUsed: number;
|
|
191
|
+
/** Remaining included slots — `null` if plan has no hard cap. */
|
|
192
|
+
remainingIncluded: number | null;
|
|
193
|
+
/** True if next workflow create will be billed as overage. */
|
|
194
|
+
nextIsOverage: boolean;
|
|
195
|
+
}
|
|
196
|
+
export interface InvoiceListItem {
|
|
197
|
+
/** Stripe invoice id (`in_…`). */
|
|
198
|
+
id: string;
|
|
199
|
+
status: string;
|
|
200
|
+
amountDueCents: number;
|
|
201
|
+
amountPaidCents: number;
|
|
202
|
+
currency: string;
|
|
203
|
+
hostedInvoiceUrl?: string;
|
|
204
|
+
invoicePdfUrl?: string;
|
|
205
|
+
periodStart?: string;
|
|
206
|
+
periodEnd?: string;
|
|
207
|
+
paidAt?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Invoice subtotal **before** any discount (cents). Populated whenever the
|
|
210
|
+
* invoice carries a `total_discount_amounts > 0` — used by the FE to show
|
|
211
|
+
* a "Subtotal / Discount / Total" breakdown. `undefined` on discount-free
|
|
212
|
+
* invoices (the FE just shows the single total).
|
|
213
|
+
*/
|
|
214
|
+
subtotalAmountCents?: number;
|
|
215
|
+
/** Total discount applied across all line items (cents, positive number). */
|
|
216
|
+
discountAmountCents?: number;
|
|
217
|
+
/** Pre-formatted label, e.g. "20% off (LAUNCH20)". */
|
|
218
|
+
discountLabel?: string;
|
|
219
|
+
}
|
|
220
|
+
export interface InvoiceListResp {
|
|
221
|
+
data: InvoiceListItem[];
|
|
222
|
+
nextCursor?: string;
|
|
223
|
+
}
|
|
224
|
+
export interface StartCheckoutReq {
|
|
225
|
+
planCode: PlanCode;
|
|
226
|
+
}
|
|
227
|
+
export interface StartCheckoutResp {
|
|
228
|
+
checkoutUrl: string;
|
|
229
|
+
sessionId: string;
|
|
230
|
+
}
|
|
231
|
+
export interface OpenPortalResp {
|
|
232
|
+
portalUrl: string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Returned with HTTP 403 when a Free org tries to create a 4th workflow.
|
|
236
|
+
* The FE intercepts this code and renders the upgrade modal directly from
|
|
237
|
+
* the response — no extra round-trip needed.
|
|
238
|
+
*/
|
|
239
|
+
export interface QuotaExceededErrorBody {
|
|
240
|
+
code: 'quota_exceeded';
|
|
241
|
+
message: string;
|
|
242
|
+
currentPlan: PlanCode;
|
|
243
|
+
limit: number;
|
|
244
|
+
used: number;
|
|
245
|
+
upgradeUrl: string;
|
|
246
|
+
}
|
|
247
|
+
export declare const QUOTA_EXCEEDED_ERROR_CODE = "quota_exceeded";
|
|
248
|
+
/**
|
|
249
|
+
* Returned with HTTP 403 when an org tries to create a Live workflow but
|
|
250
|
+
* their subscription is in a terminal / pending state (canceled, incomplete,
|
|
251
|
+
* unpaid, paused, …). Distinct from `quota_exceeded` because the user
|
|
252
|
+
* remediation is different — they need to update billing or re-subscribe,
|
|
253
|
+
* not just stay under the cap.
|
|
254
|
+
*/
|
|
255
|
+
export interface SubscriptionInactiveErrorBody {
|
|
256
|
+
code: 'subscription_inactive';
|
|
257
|
+
message: string;
|
|
258
|
+
currentPlan: PlanCode;
|
|
259
|
+
status: SubscriptionStatus;
|
|
260
|
+
upgradeUrl: string;
|
|
261
|
+
}
|
|
262
|
+
export declare const SUBSCRIPTION_INACTIVE_ERROR_CODE = "subscription_inactive";
|
|
263
|
+
/**
|
|
264
|
+
* Statuses that grant Live workflow access. Used both server-side (gate in
|
|
265
|
+
* `UsageMeterService.checkQuota`) and client-side (UI hides the upgrade
|
|
266
|
+
* warning when this returns true).
|
|
267
|
+
*
|
|
268
|
+
* - `active` — Free (always active) and Pro (paid + current)
|
|
269
|
+
* - `trialing` — would apply once trials are introduced (additive, no
|
|
270
|
+
* schema change)
|
|
271
|
+
* - `past_due` — Pro user with a failed payment. We deliberately keep
|
|
272
|
+
* access during Stripe's retry window so the user can
|
|
273
|
+
* fix their card without losing service. Stripe's
|
|
274
|
+
* Dashboard-configured retry rules eventually cancel
|
|
275
|
+
* the sub after retries exhaust, and the
|
|
276
|
+
* `customer.subscription.deleted` webhook downgrades
|
|
277
|
+
* the org back to Free.
|
|
278
|
+
*/
|
|
279
|
+
export declare function isSubscriptionActive(status: SubscriptionStatus): boolean;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Subscription / billing shared types.
|
|
4
|
+
*
|
|
5
|
+
* Money is always integer cents — never floats. Currency formatting happens
|
|
6
|
+
* in the FE display layer.
|
|
7
|
+
*
|
|
8
|
+
* IDs:
|
|
9
|
+
* - Internal subscription doc id is prefixed `bsub_…` (billing subscription)
|
|
10
|
+
* to avoid colliding with Stripe's own `sub_…` ids. Stripe's id lives in
|
|
11
|
+
* `stripeSubscriptionId`.
|
|
12
|
+
* - Internal usage-period doc id is prefixed `up_…`.
|
|
13
|
+
* - Internal usage-event doc id is prefixed `ue_…`.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.SUBSCRIPTION_INACTIVE_ERROR_CODE = exports.QUOTA_EXCEEDED_ERROR_CODE = exports.UsageBillingCategory = exports.SubscriptionStatus = exports.PlanCode = void 0;
|
|
17
|
+
exports.isSubscriptionActive = isSubscriptionActive;
|
|
18
|
+
var PlanCode;
|
|
19
|
+
(function (PlanCode) {
|
|
20
|
+
PlanCode["Free"] = "free";
|
|
21
|
+
PlanCode["Pro"] = "pro";
|
|
22
|
+
})(PlanCode || (exports.PlanCode = PlanCode = {}));
|
|
23
|
+
/**
|
|
24
|
+
* 1:1 mirror of Stripe's subscription status enum. **All values are intentional**
|
|
25
|
+
* even though only a subset drives bespoke code paths — the schema's Mongoose
|
|
26
|
+
* `enum` validator rejects writes with unknown values, so every status Stripe
|
|
27
|
+
* may emit must be listed here or the corresponding webhook update crashes
|
|
28
|
+
* mid-write and the local doc drifts.
|
|
29
|
+
*
|
|
30
|
+
* Three categories (see the grouped sections below):
|
|
31
|
+
*
|
|
32
|
+
* 1. **Active states** — `isSubscriptionActive()` returns true; the org can
|
|
33
|
+
* create Live workflows. Includes `past_due` because we honour the grace
|
|
34
|
+
* period before locking access.
|
|
35
|
+
*
|
|
36
|
+
* 2. **Terminal states** — `applySubscriptionUpdate` flips the org back to
|
|
37
|
+
* the Free baseline via `transitionToFree`.
|
|
38
|
+
*
|
|
39
|
+
* 3. **Pass-through states** — accepted by the schema so webhooks don't
|
|
40
|
+
* crash, but no bespoke handler. Stripe is the system of record; if any
|
|
41
|
+
* of these starts mattering to a feature, add the handler then.
|
|
42
|
+
*
|
|
43
|
+
* Reference: https://stripe.com/docs/api/subscriptions/object#subscription_object-status
|
|
44
|
+
*/
|
|
45
|
+
var SubscriptionStatus;
|
|
46
|
+
(function (SubscriptionStatus) {
|
|
47
|
+
// ─── Active states — grant Live workflow access ──────────────────────────
|
|
48
|
+
SubscriptionStatus["Active"] = "active";
|
|
49
|
+
/** Pro user with a failed payment. Stripe retries on its retry schedule
|
|
50
|
+
* (configured in the Dashboard) and auto-cancels if retries exhaust;
|
|
51
|
+
* we keep access active during this window. */
|
|
52
|
+
SubscriptionStatus["PastDue"] = "past_due";
|
|
53
|
+
/** Reserved — we don't ship trials today, but the access gate already
|
|
54
|
+
* treats this as active so adding trials is purely a Stripe-side change. */
|
|
55
|
+
SubscriptionStatus["Trialing"] = "trialing";
|
|
56
|
+
// ─── Terminal states — trigger transition back to Free ───────────────────
|
|
57
|
+
/** User canceled (immediate or via Customer Portal). */
|
|
58
|
+
SubscriptionStatus["Canceled"] = "canceled";
|
|
59
|
+
/** First-invoice payment never cleared within Stripe's ~23h window. */
|
|
60
|
+
SubscriptionStatus["IncompleteExpired"] = "incomplete_expired";
|
|
61
|
+
// ─── Pass-through states — accepted, no bespoke handling ─────────────────
|
|
62
|
+
/** Initial state for every Stripe-created sub before the first payment
|
|
63
|
+
* attempt resolves — typically flips to `active` within seconds via the
|
|
64
|
+
* follow-up `customer.subscription.updated` event. */
|
|
65
|
+
SubscriptionStatus["Incomplete"] = "incomplete";
|
|
66
|
+
/** Stripe-emitted after retries exhaust mid-cycle. We don't act on this
|
|
67
|
+
* directly — the next `past_due → cancel` cycle (or operator action)
|
|
68
|
+
* resolves the sub. */
|
|
69
|
+
SubscriptionStatus["Unpaid"] = "unpaid";
|
|
70
|
+
/** Customer Portal pause. We don't expose pause as a product feature, so
|
|
71
|
+
* the doc just mirrors Stripe and the org keeps its current access until
|
|
72
|
+
* Stripe transitions it to a real terminal state. */
|
|
73
|
+
SubscriptionStatus["Paused"] = "paused";
|
|
74
|
+
})(SubscriptionStatus || (exports.SubscriptionStatus = SubscriptionStatus = {}));
|
|
75
|
+
var UsageBillingCategory;
|
|
76
|
+
(function (UsageBillingCategory) {
|
|
77
|
+
/** Counted against the plan's included quota. */
|
|
78
|
+
UsageBillingCategory["Included"] = "included";
|
|
79
|
+
/** Charged as overage via Stripe metered Price. */
|
|
80
|
+
UsageBillingCategory["Overage"] = "overage";
|
|
81
|
+
})(UsageBillingCategory || (exports.UsageBillingCategory = UsageBillingCategory = {}));
|
|
82
|
+
exports.QUOTA_EXCEEDED_ERROR_CODE = 'quota_exceeded';
|
|
83
|
+
exports.SUBSCRIPTION_INACTIVE_ERROR_CODE = 'subscription_inactive';
|
|
84
|
+
/**
|
|
85
|
+
* Statuses that grant Live workflow access. Used both server-side (gate in
|
|
86
|
+
* `UsageMeterService.checkQuota`) and client-side (UI hides the upgrade
|
|
87
|
+
* warning when this returns true).
|
|
88
|
+
*
|
|
89
|
+
* - `active` — Free (always active) and Pro (paid + current)
|
|
90
|
+
* - `trialing` — would apply once trials are introduced (additive, no
|
|
91
|
+
* schema change)
|
|
92
|
+
* - `past_due` — Pro user with a failed payment. We deliberately keep
|
|
93
|
+
* access during Stripe's retry window so the user can
|
|
94
|
+
* fix their card without losing service. Stripe's
|
|
95
|
+
* Dashboard-configured retry rules eventually cancel
|
|
96
|
+
* the sub after retries exhaust, and the
|
|
97
|
+
* `customer.subscription.deleted` webhook downgrades
|
|
98
|
+
* the org back to Free.
|
|
99
|
+
*/
|
|
100
|
+
function isSubscriptionActive(status) {
|
|
101
|
+
return (status === SubscriptionStatus.Active ||
|
|
102
|
+
status === SubscriptionStatus.Trialing ||
|
|
103
|
+
status === SubscriptionStatus.PastDue);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../../../../../../../../libs/signstack/base/src/lib/models/subscription.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AA2TH,oDAMC;AA/TD,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,uBAAW,CAAA;AACb,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,IAAY,kBA8BX;AA9BD,WAAY,kBAAkB;IAC5B,4EAA4E;IAC5E,uCAAiB,CAAA;IACjB;;oDAEgD;IAChD,0CAAoB,CAAA;IACpB;iFAC6E;IAC7E,2CAAqB,CAAA;IAErB,4EAA4E;IAC5E,wDAAwD;IACxD,2CAAqB,CAAA;IACrB,uEAAuE;IACvE,8DAAwC,CAAA;IAExC,4EAA4E;IAC5E;;2DAEuD;IACvD,+CAAyB,CAAA;IACzB;;4BAEwB;IACxB,uCAAiB,CAAA;IACjB;;0DAEsD;IACtD,uCAAiB,CAAA;AACnB,CAAC,EA9BW,kBAAkB,kCAAlB,kBAAkB,QA8B7B;AAED,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,iDAAiD;IACjD,6CAAqB,CAAA;IACrB,mDAAmD;IACnD,2CAAmB,CAAA;AACrB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B;AAsNY,QAAA,yBAAyB,GAAG,gBAAgB,CAAC;AAiB7C,QAAA,gCAAgC,GAAG,uBAAuB,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,oBAAoB,CAAC,MAA0B;IAC7D,OAAO,CACL,MAAM,KAAK,kBAAkB,CAAC,MAAM;QACpC,MAAM,KAAK,kBAAkB,CAAC,QAAQ;QACtC,MAAM,KAAK,kBAAkB,CAAC,OAAO,CACtC,CAAC;AACJ,CAAC"}
|