@volter/twin-polar 2.0.37 → 3.0.0

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.
Files changed (121) hide show
  1. package/README.md +24 -27
  2. package/dist/generated/pack-facts.json +69 -0
  3. package/dist/journeys/coverage.json +223 -0
  4. package/dist/journeys/customer-life.json +1222 -0
  5. package/dist/journeys/customer-life.outline.md +69 -0
  6. package/dist/journeys/customer-life.outline.verdict.json +41 -0
  7. package/dist/journeys/customer-life.verdict.json +71 -0
  8. package/dist/journeys/decisions.json +149 -0
  9. package/dist/journeys/demand.json +45 -0
  10. package/dist/journeys/score.json +249 -0
  11. package/dist/journeys/unreachable.json +13 -0
  12. package/dist/journeys/vendor-examples.json +9621 -0
  13. package/dist/journeys/vendor-examples.verdict.json +33 -0
  14. package/dist/spec/SOURCE.md +25 -0
  15. package/dist/spec/doc-examples.json +681 -0
  16. package/dist/spec/openapi.json.gz +0 -0
  17. package/dist/spec/sources.json +71 -0
  18. package/dist/src/cli.js +7 -16
  19. package/dist/src/fetch.d.ts +2 -0
  20. package/dist/src/fetch.js +24 -0
  21. package/dist/src/generated/surface.gen.json +1 -0
  22. package/dist/src/generated/ui.gen.json +1 -0
  23. package/dist/src/index.d.ts +5 -9
  24. package/dist/src/index.js +10 -55
  25. package/dist/src/manifest.d.ts +2 -0
  26. package/dist/src/manifest.js +123 -0
  27. package/dist/src/screens/checkout.d.ts +2 -0
  28. package/dist/src/screens/checkout.js +25 -0
  29. package/dist/src/screens/portal.d.ts +2 -0
  30. package/dist/src/screens/portal.js +18 -0
  31. package/dist/src/semantics/around.d.ts +2 -0
  32. package/dist/src/semantics/around.js +25 -0
  33. package/dist/src/semantics/checkouts.d.ts +14 -0
  34. package/dist/src/semantics/checkouts.js +131 -0
  35. package/dist/src/semantics/clock.d.ts +2 -0
  36. package/dist/src/semantics/clock.js +22 -0
  37. package/dist/src/semantics/customer-sessions.d.ts +2 -0
  38. package/dist/src/semantics/customer-sessions.js +12 -0
  39. package/dist/src/semantics/customers.d.ts +9 -0
  40. package/dist/src/semantics/customers.js +61 -0
  41. package/dist/src/semantics/doors.d.ts +11 -0
  42. package/dist/src/semantics/doors.js +47 -0
  43. package/dist/src/semantics/events.d.ts +12 -0
  44. package/dist/src/semantics/events.js +60 -0
  45. package/dist/src/semantics/index.d.ts +2 -0
  46. package/dist/src/semantics/index.js +27 -0
  47. package/dist/src/semantics/orders.d.ts +4 -0
  48. package/dist/src/semantics/orders.js +11 -0
  49. package/dist/src/semantics/products.d.ts +5 -0
  50. package/dist/src/semantics/products.js +43 -0
  51. package/dist/src/semantics/shared.d.ts +82 -0
  52. package/dist/src/semantics/shared.js +327 -0
  53. package/dist/src/semantics/states.d.ts +27 -0
  54. package/dist/src/semantics/states.js +43 -0
  55. package/dist/src/semantics/subscriptions.d.ts +4 -0
  56. package/dist/src/semantics/subscriptions.js +15 -0
  57. package/dist/src/semantics/tenant.d.ts +2 -0
  58. package/dist/src/semantics/tenant.js +2 -0
  59. package/dist/src/semantics/webhooks.d.ts +4 -0
  60. package/dist/src/semantics/webhooks.js +30 -0
  61. package/dist/src/server.d.ts +7 -0
  62. package/dist/src/server.js +7 -0
  63. package/generated/pack-facts.json +69 -0
  64. package/journeys/coverage.json +223 -0
  65. package/journeys/customer-life.json +1222 -0
  66. package/journeys/customer-life.outline.md +69 -0
  67. package/journeys/customer-life.outline.verdict.json +41 -0
  68. package/journeys/customer-life.verdict.json +71 -0
  69. package/journeys/decisions.json +149 -0
  70. package/journeys/demand.json +45 -0
  71. package/journeys/score.json +249 -0
  72. package/journeys/unreachable.json +13 -0
  73. package/journeys/vendor-examples.json +9621 -0
  74. package/journeys/vendor-examples.verdict.json +33 -0
  75. package/package.json +19 -31
  76. package/spec/SOURCE.md +25 -0
  77. package/spec/doc-examples.json +681 -0
  78. package/spec/openapi.json.gz +0 -0
  79. package/spec/sources.json +71 -0
  80. package/src/cli.ts +7 -14
  81. package/src/fetch.ts +25 -0
  82. package/src/generated/surface.gen.json +1 -0
  83. package/src/generated/ui.gen.json +1 -0
  84. package/src/index.ts +11 -85
  85. package/src/manifest.ts +135 -0
  86. package/src/screens/checkout.ts +33 -0
  87. package/src/screens/portal.ts +20 -0
  88. package/src/semantics/around.ts +25 -0
  89. package/src/semantics/checkouts.ts +133 -0
  90. package/src/semantics/clock.ts +24 -0
  91. package/src/semantics/customer-sessions.ts +13 -0
  92. package/src/semantics/customers.ts +68 -0
  93. package/src/semantics/doors.ts +51 -0
  94. package/src/semantics/events.ts +62 -0
  95. package/src/semantics/index.ts +31 -0
  96. package/src/semantics/orders.ts +15 -0
  97. package/src/semantics/products.ts +45 -0
  98. package/src/semantics/shared.ts +352 -0
  99. package/src/semantics/states.ts +50 -0
  100. package/src/semantics/subscriptions.ts +18 -0
  101. package/src/semantics/tenant.ts +5 -0
  102. package/src/semantics/webhooks.ts +29 -0
  103. package/src/server.ts +8 -0
  104. package/dist/src/polar-budget.d.ts +0 -83
  105. package/dist/src/polar-budget.js +0 -413
  106. package/dist/src/polar-capabilities.d.ts +0 -4
  107. package/dist/src/polar-capabilities.js +0 -389
  108. package/dist/src/polar-conformance.d.ts +0 -7
  109. package/dist/src/polar-conformance.js +0 -25
  110. package/dist/src/polar-connector.d.ts +0 -113
  111. package/dist/src/polar-connector.js +0 -146
  112. package/dist/src/polar-server.d.ts +0 -14
  113. package/dist/src/polar-server.js +0 -52
  114. package/dist/src/polar-twin.d.ts +0 -24
  115. package/dist/src/polar-twin.js +0 -941
  116. package/src/polar-budget.ts +0 -459
  117. package/src/polar-capabilities.ts +0 -448
  118. package/src/polar-conformance.ts +0 -33
  119. package/src/polar-connector.ts +0 -172
  120. package/src/polar-server.ts +0 -57
  121. package/src/polar-twin.ts +0 -938
Binary file
@@ -0,0 +1,71 @@
1
+ {
2
+ "https://polar.sh/docs/api-reference/introduction": {
3
+ "status": 200,
4
+ "checked": "2026-10-01",
5
+ "quotes": {
6
+ "Create separate tokens in each environment.": true,
7
+ "500 requests per minute": true,
8
+ "100 requests per minute": true
9
+ }
10
+ },
11
+ "https://polar.sh/docs/features/checkout/session": {
12
+ "status": 200,
13
+ "checked": "2026-10-03",
14
+ "quotes": {
15
+ "Ad-hoc prices are temporary prices that exist only for that specific checkout session": true
16
+ }
17
+ },
18
+ "https://polar.sh/docs/features/customer-portal": {
19
+ "status": 200,
20
+ "checked": "2026-10-03",
21
+ "quotes": {
22
+ "active subscriptions": true
23
+ }
24
+ },
25
+ "https://polar.sh/docs/features/customer-portal/navigate-customers": {
26
+ "status": 200,
27
+ "checked": "2026-10-03",
28
+ "quotes": {
29
+ "no email code required": true
30
+ }
31
+ },
32
+ "https://polar.sh/docs/features/subscriptions/introduction": {
33
+ "status": 200,
34
+ "checked": "2026-10-01",
35
+ "quotes": {
36
+ "At the end of each billing period, Polar advances the subscription to the next cycle and creates a new order": true,
37
+ "creates a new order": true,
38
+ "Daily, weekly, monthly or yearly.": true
39
+ }
40
+ },
41
+ "https://polar.sh/docs/features/subscriptions/trials": {
42
+ "status": 200,
43
+ "checked": "2026-10-01",
44
+ "quotes": {
45
+ "they will not be charged immediately": true,
46
+ "Once the trial period ends, the customer will be automatically charged for the subscription, and their billing cycle will begin.": true
47
+ }
48
+ },
49
+ "https://polar.sh/docs/features/usage-based-billing/event-ingestion": {
50
+ "status": 200,
51
+ "checked": "2026-10-01",
52
+ "quotes": {
53
+ "Polar never issues retroactive invoices or credits for late events.": true
54
+ }
55
+ },
56
+ "https://polar.sh/docs/features/usage-based-billing/meters": {
57
+ "status": 200,
58
+ "checked": "2026-10-01",
59
+ "quotes": {
60
+ "Counts the number of unique values of a property.": true,
61
+ "Operators are the operators that you want to use to filter the events.": true
62
+ }
63
+ },
64
+ "https://raw.githubusercontent.com/polarsource/polar/main/server/polar/config.py": {
65
+ "status": 200,
66
+ "checked": "2026-10-01",
67
+ "quotes": {
68
+ "CHECKOUT_TTL_SECONDS: int = 60 * 60 * 24": true
69
+ }
70
+ }
71
+ }
package/src/cli.ts CHANGED
@@ -1,25 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { keepProcessAlive } from '@volter/world-core/lifecycle';
3
- // world-polar CLI: serve the KERNEL-BACKED Polar API twin, or run conformance. State lives in
4
- // the @volter/world-core action log (no in-memory side-store). Conformance is dev-only + lazy-imported
5
- // so the bin runs without @volter/world-tooling (E2).
2
+ // world-polar: serve the polar twin.
6
3
  import { hasFlag, optionValue } from '@volter/world-core/args';
7
- import { createPolarTwinServer } from './polar-server.ts';
4
+ import { keepProcessAlive } from '@volter/world-core/lifecycle';
5
+ import { createPolarTwinServer } from './server.ts';
8
6
 
9
7
  const [cmd, ...rest] = process.argv.slice(2);
10
- const port = Number(optionValue(rest, '--port', String(process.env.PORT ?? '0'))) || undefined;
8
+ const port = Number(optionValue(rest, '--port', '0')) || undefined;
11
9
  const root = optionValue(rest, '--root') || undefined;
12
- const readOnly = hasFlag(rest, '--read-only'); // a twin accepts writes unless started read-only
10
+ const readOnly = hasFlag(rest, '--read-only');
13
11
 
14
12
  if (cmd === 'serve' || cmd === undefined) {
15
13
  const s = await createPolarTwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}) });
16
- process.stdout.write(`polar twin (merchant-of-record billing API)${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${s.port}\n`);
14
+ process.stdout.write(`polar twin${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${s.port}\n`);
17
15
  await keepProcessAlive();
18
- } else if (cmd === 'conformance') {
19
- const { checkPolarConformance } = await import('./polar-conformance.ts');
20
- const report = checkPolarConformance();
21
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
22
- if (!report.ok) process.exitCode = 1;
23
16
  } else {
24
- process.stdout.write('Usage: world-polar serve|conformance [--port N] [--root DIR] [--read-only]\n');
17
+ process.stdout.write('Usage: world-polar serve [--port N] [--root DIR] [--read-only]\n');
25
18
  }
package/src/fetch.ts ADDED
@@ -0,0 +1,25 @@
1
+ // GENERATED by scripts/create-pack.ts (--init, --index): a fixed file. The kernel serves the discovery door, the clock,
2
+ // the World's doors, the vendor's screens and the API from the pack's parts (architecture, "The pack contract").
3
+ import { createPackFetch, type DerivedFetch, type DerivedSurface, type PackFetchOptions } from '@volter/world-core';
4
+ import surface from './generated/surface.gen.json' with { type: 'json' };
5
+ import { manifest } from './manifest.ts';
6
+ import { around } from './semantics/around.ts';
7
+ import { clock } from './semantics/clock.ts';
8
+ import { tenant } from './semantics/tenant.ts';
9
+ import * as doors from './semantics/doors.ts';
10
+ import { polarSemantics } from './semantics/index.ts';
11
+ import { screen as screen_checkout } from './screens/checkout.ts';
12
+ import { screen as screen_portal } from './screens/portal.ts';
13
+
14
+ export function createPolarFetch(options: PackFetchOptions = {}): DerivedFetch {
15
+ return createPackFetch({
16
+ manifest,
17
+ surface: surface as DerivedSurface,
18
+ handlers: polarSemantics,
19
+ doors,
20
+ around,
21
+ clock,
22
+ tenant,
23
+ screens: { "checkout": screen_checkout, "portal": screen_portal },
24
+ }, options);
25
+ }