@tollwyn/baukasten 0.0.2 → 1.2.3

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 (213) hide show
  1. package/README.md +254 -1
  2. package/dist/bin/check.d.ts +2 -0
  3. package/dist/bin/check.js +38 -0
  4. package/dist/bin/migrate.d.ts +2 -0
  5. package/dist/bin/migrate.js +111 -0
  6. package/dist/bin/stubs.d.ts +2 -0
  7. package/dist/bin/stubs.js +38 -0
  8. package/dist/bin/test-accounts.d.ts +2 -0
  9. package/dist/bin/test-accounts.js +62 -0
  10. package/dist/check.d.ts +20 -0
  11. package/dist/check.js +285 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.js +9 -0
  14. package/dist/product.d.ts +161 -0
  15. package/dist/product.js +152 -0
  16. package/dist/server/accounts.d.ts +128 -0
  17. package/dist/server/accounts.js +282 -0
  18. package/dist/server/adapter/db.d.ts +5 -0
  19. package/dist/server/adapter/db.js +63 -0
  20. package/dist/server/adapter/log.d.ts +3 -0
  21. package/dist/server/adapter/log.js +12 -0
  22. package/dist/server/adapter/mailer.d.ts +4 -0
  23. package/dist/server/adapter/mailer.js +56 -0
  24. package/dist/server/adapter/migrate.d.ts +21 -0
  25. package/dist/server/adapter/migrate.js +113 -0
  26. package/dist/server/adapter/secrets.d.ts +2 -0
  27. package/dist/server/adapter/secrets.js +40 -0
  28. package/dist/server/adapter/stripe.d.ts +11 -0
  29. package/dist/server/adapter/stripe.js +333 -0
  30. package/dist/server/api.d.ts +25 -0
  31. package/dist/server/api.js +98 -0
  32. package/dist/server/baukasten-migrations.d.ts +4 -0
  33. package/dist/server/baukasten-migrations.js +126 -0
  34. package/dist/server/billing.d.ts +94 -0
  35. package/dist/server/billing.js +349 -0
  36. package/dist/server/catalog.d.ts +39 -0
  37. package/dist/server/catalog.js +193 -0
  38. package/dist/server/config.d.ts +108 -0
  39. package/dist/server/config.js +244 -0
  40. package/dist/server/endpoints.d.ts +44 -0
  41. package/dist/server/endpoints.js +159 -0
  42. package/dist/server/fields.d.ts +7 -0
  43. package/dist/server/fields.js +18 -0
  44. package/dist/server/headers.d.ts +1 -0
  45. package/dist/server/headers.js +9 -0
  46. package/dist/server/health.d.ts +34 -0
  47. package/dist/server/health.js +116 -0
  48. package/dist/server/hook.d.ts +92 -0
  49. package/dist/server/hook.js +293 -0
  50. package/dist/server/index.d.ts +18 -0
  51. package/dist/server/index.js +11 -0
  52. package/dist/server/legal/de.d.ts +2 -0
  53. package/dist/server/legal/de.js +251 -0
  54. package/dist/server/legal/document.d.ts +37 -0
  55. package/dist/server/legal/document.js +30 -0
  56. package/dist/server/legal/en.d.ts +2 -0
  57. package/dist/server/legal/en.js +251 -0
  58. package/dist/server/legal/fleet.d.ts +114 -0
  59. package/dist/server/legal/fleet.js +89 -0
  60. package/dist/server/legal/index.d.ts +3 -0
  61. package/dist/server/legal/index.js +11 -0
  62. package/dist/server/limits.d.ts +58 -0
  63. package/dist/server/limits.js +76 -0
  64. package/dist/server/log.d.ts +26 -0
  65. package/dist/server/log.js +61 -0
  66. package/dist/server/machine.d.ts +4 -0
  67. package/dist/server/machine.js +57 -0
  68. package/dist/server/mail.d.ts +20 -0
  69. package/dist/server/mail.js +29 -0
  70. package/dist/server/messages.d.ts +105 -0
  71. package/dist/server/messages.js +232 -0
  72. package/dist/server/migrations.d.ts +28 -0
  73. package/dist/server/migrations.js +59 -0
  74. package/dist/server/openapi.d.ts +24 -0
  75. package/dist/server/openapi.js +173 -0
  76. package/dist/server/pages.d.ts +158 -0
  77. package/dist/server/pages.js +491 -0
  78. package/dist/server/ports.d.ts +273 -0
  79. package/dist/server/ports.js +1 -0
  80. package/dist/server/runs.d.ts +30 -0
  81. package/dist/server/runs.js +55 -0
  82. package/dist/server/sales.d.ts +38 -0
  83. package/dist/server/sales.js +132 -0
  84. package/dist/server/services.d.ts +57 -0
  85. package/dist/server/services.js +44 -0
  86. package/dist/server/start.d.ts +14 -0
  87. package/dist/server/start.js +65 -0
  88. package/dist/server/stripe.d.ts +33 -0
  89. package/dist/server/stripe.js +29 -0
  90. package/dist/server/terms.d.ts +7 -0
  91. package/dist/server/terms.js +9 -0
  92. package/dist/server/test-accounts.d.ts +28 -0
  93. package/dist/server/test-accounts.js +62 -0
  94. package/dist/server/via.d.ts +9 -0
  95. package/dist/server/via.js +15 -0
  96. package/dist/server/web.d.ts +48 -0
  97. package/dist/server/web.js +105 -0
  98. package/dist/shopify/adapter/shopify.d.ts +8 -0
  99. package/dist/shopify/adapter/shopify.js +232 -0
  100. package/dist/shopify/admin.d.ts +33 -0
  101. package/dist/shopify/admin.js +47 -0
  102. package/dist/shopify/app.d.ts +60 -0
  103. package/dist/shopify/app.js +67 -0
  104. package/dist/shopify/config.d.ts +53 -0
  105. package/dist/shopify/config.js +133 -0
  106. package/dist/shopify/constants.d.ts +27 -0
  107. package/dist/shopify/constants.js +27 -0
  108. package/dist/shopify/headers.d.ts +1 -0
  109. package/dist/shopify/headers.js +8 -0
  110. package/dist/shopify/hmac.d.ts +1 -0
  111. package/dist/shopify/hmac.js +9 -0
  112. package/dist/shopify/hook.d.ts +60 -0
  113. package/dist/shopify/hook.js +508 -0
  114. package/dist/shopify/id-token.d.ts +12 -0
  115. package/dist/shopify/id-token.js +66 -0
  116. package/dist/shopify/index.d.ts +19 -0
  117. package/dist/shopify/index.js +15 -0
  118. package/dist/shopify/legal/de.d.ts +3 -0
  119. package/dist/shopify/legal/de.js +123 -0
  120. package/dist/shopify/legal/en.d.ts +3 -0
  121. package/dist/shopify/legal/en.js +121 -0
  122. package/dist/shopify/legal/index.d.ts +19 -0
  123. package/dist/shopify/legal/index.js +8 -0
  124. package/dist/shopify/legal/shopify.d.ts +16 -0
  125. package/dist/shopify/legal/shopify.js +21 -0
  126. package/dist/shopify/migrations.d.ts +4 -0
  127. package/dist/shopify/migrations.js +67 -0
  128. package/dist/shopify/pages.d.ts +45 -0
  129. package/dist/shopify/pages.js +146 -0
  130. package/dist/shopify/ports.d.ts +77 -0
  131. package/dist/shopify/ports.js +1 -0
  132. package/dist/shopify/sales.d.ts +4 -0
  133. package/dist/shopify/sales.js +27 -0
  134. package/dist/shopify/scopes.d.ts +2 -0
  135. package/dist/shopify/scopes.js +13 -0
  136. package/dist/shopify/seal.d.ts +12 -0
  137. package/dist/shopify/seal.js +60 -0
  138. package/dist/shopify/shop.d.ts +4 -0
  139. package/dist/shopify/shop.js +15 -0
  140. package/dist/shopify/shops.d.ts +76 -0
  141. package/dist/shopify/shops.js +256 -0
  142. package/dist/shopify/sveltekit.d.ts +19 -0
  143. package/dist/shopify/sveltekit.js +18 -0
  144. package/dist/shopify/texts.d.ts +28 -0
  145. package/dist/shopify/texts.js +49 -0
  146. package/dist/shopify/toml.d.ts +22 -0
  147. package/dist/shopify/toml.js +125 -0
  148. package/dist/shopify/webhooks.d.ts +65 -0
  149. package/dist/shopify/webhooks.js +220 -0
  150. package/dist/stubs.d.ts +15 -0
  151. package/dist/stubs.js +287 -0
  152. package/dist/sveltekit.d.ts +20 -0
  153. package/dist/sveltekit.js +18 -0
  154. package/dist/testing/app.d.ts +36 -0
  155. package/dist/testing/app.js +155 -0
  156. package/dist/testing/browser.d.ts +21 -0
  157. package/dist/testing/browser.js +21 -0
  158. package/dist/testing/connection.d.ts +7 -0
  159. package/dist/testing/connection.js +303 -0
  160. package/dist/testing/database.d.ts +21 -0
  161. package/dist/testing/database.js +54 -0
  162. package/dist/testing/env-example.d.ts +4 -0
  163. package/dist/testing/env-example.js +33 -0
  164. package/dist/testing/index.d.ts +9 -0
  165. package/dist/testing/index.js +9 -0
  166. package/dist/testing/shopify-connection.d.ts +8 -0
  167. package/dist/testing/shopify-connection.js +313 -0
  168. package/dist/testing/shopify.d.ts +71 -0
  169. package/dist/testing/shopify.js +278 -0
  170. package/dist/testing/smtp.d.ts +38 -0
  171. package/dist/testing/smtp.js +165 -0
  172. package/dist/testing/stripe.d.ts +128 -0
  173. package/dist/testing/stripe.js +511 -0
  174. package/dist/texts.d.ts +139 -0
  175. package/dist/texts.js +265 -0
  176. package/dist/ui/AccountPage.svelte +143 -0
  177. package/dist/ui/AccountPage.svelte.d.ts +10 -0
  178. package/dist/ui/ConfirmEmailPage.svelte +21 -0
  179. package/dist/ui/ConfirmEmailPage.svelte.d.ts +10 -0
  180. package/dist/ui/ErrorPage.svelte +14 -0
  181. package/dist/ui/ErrorPage.svelte.d.ts +3 -0
  182. package/dist/ui/Field.svelte +12 -0
  183. package/dist/ui/Field.svelte.d.ts +10 -0
  184. package/dist/ui/ForgotPasswordPage.svelte +32 -0
  185. package/dist/ui/ForgotPasswordPage.svelte.d.ts +7 -0
  186. package/dist/ui/Form.svelte +30 -0
  187. package/dist/ui/Form.svelte.d.ts +11 -0
  188. package/dist/ui/Frame.svelte +84 -0
  189. package/dist/ui/Frame.svelte.d.ts +12 -0
  190. package/dist/ui/LegalPage.svelte +38 -0
  191. package/dist/ui/LegalPage.svelte.d.ts +9 -0
  192. package/dist/ui/Linked.svelte +5 -0
  193. package/dist/ui/Linked.svelte.d.ts +8 -0
  194. package/dist/ui/LoginPage.svelte +41 -0
  195. package/dist/ui/LoginPage.svelte.d.ts +10 -0
  196. package/dist/ui/LogoutPage.svelte +19 -0
  197. package/dist/ui/LogoutPage.svelte.d.ts +9 -0
  198. package/dist/ui/ResetPasswordPage.svelte +30 -0
  199. package/dist/ui/ResetPasswordPage.svelte.d.ts +10 -0
  200. package/dist/ui/SignupPage.svelte +52 -0
  201. package/dist/ui/SignupPage.svelte.d.ts +10 -0
  202. package/dist/ui/VerifyEmailPage.svelte +50 -0
  203. package/dist/ui/VerifyEmailPage.svelte.d.ts +10 -0
  204. package/dist/ui/base.css +287 -0
  205. package/dist/ui/data.d.ts +167 -0
  206. package/dist/ui/data.js +1 -0
  207. package/dist/ui/frame.d.ts +17 -0
  208. package/dist/ui/frame.js +27 -0
  209. package/dist/ui/index.d.ts +15 -0
  210. package/dist/ui/index.js +15 -0
  211. package/dist/variables.d.ts +20 -0
  212. package/dist/variables.js +62 -0
  213. package/package.json +88 -4
@@ -0,0 +1,173 @@
1
+ import { API_PATHS } from './endpoints.js';
2
+ const ref = (name) => ({ $ref: `#/components/schemas/${name}` });
3
+ const json = (schema) => ({ 'application/json': { schema } });
4
+ export function openApiPart(origin, messages) {
5
+ const o = messages.openApi;
6
+ const error = (description) => ({ description, content: json(ref('Error')) });
7
+ return {
8
+ paths: {
9
+ [API_PATHS.signup]: {
10
+ post: {
11
+ operationId: 'signUp',
12
+ summary: o.signup,
13
+ security: [],
14
+ requestBody: {
15
+ required: true,
16
+ content: json({
17
+ type: 'object',
18
+ required: ['email', 'accept_terms', 'acting_for_business'],
19
+ properties: {
20
+ email: { type: 'string', format: 'email', maxLength: 254, description: o.email },
21
+ accept_terms: {
22
+ type: 'boolean',
23
+ const: true,
24
+ description: `${o.acceptTerms} ${origin}/terms`
25
+ },
26
+ acting_for_business: {
27
+ type: 'boolean',
28
+ const: true,
29
+ description: o.actingForBusiness
30
+ },
31
+ via: {
32
+ type: 'string',
33
+ maxLength: 32,
34
+ pattern: '^[a-z0-9]+(-[a-z0-9]+)*$',
35
+ description: o.via
36
+ }
37
+ }
38
+ })
39
+ },
40
+ responses: {
41
+ '201': {
42
+ description: o.signupCreated,
43
+ content: json({
44
+ type: 'object',
45
+ required: ['api_key', 'account'],
46
+ properties: { api_key: { type: 'string' }, account: ref('Account') }
47
+ })
48
+ },
49
+ '400': error(o.errors.invalidJson),
50
+ '403': error(o.errors.forbidden),
51
+ '409': error(o.errors.emailTaken),
52
+ '422': error(o.errors.invalidRequest),
53
+ '429': error(o.errors.rateLimited)
54
+ }
55
+ }
56
+ },
57
+ [API_PATHS.account]: {
58
+ get: {
59
+ operationId: 'getAccount',
60
+ summary: o.account,
61
+ security: [{ apiKey: [] }],
62
+ responses: {
63
+ '200': { description: o.account, content: json(ref('Account')) },
64
+ '401': error(o.errors.unauthorized),
65
+ '429': error(o.errors.rateLimited)
66
+ }
67
+ }
68
+ },
69
+ [API_PATHS.checkout]: {
70
+ post: {
71
+ operationId: 'openCheckout',
72
+ summary: o.checkout,
73
+ description: o.checkoutBody,
74
+ security: [{ apiKey: [] }],
75
+ requestBody: {
76
+ required: true,
77
+ content: json({
78
+ type: 'object',
79
+ required: ['price'],
80
+ properties: {
81
+ price: { type: 'string', description: o.price },
82
+ quantity: { type: 'integer', minimum: 1, description: o.quantity }
83
+ }
84
+ })
85
+ },
86
+ responses: {
87
+ '200': { description: o.url, content: json(ref('Url')) },
88
+ '400': error(o.errors.invalidJson),
89
+ '401': error(o.errors.unauthorized),
90
+ '409': error(o.errors.subscribed),
91
+ '422': error(o.errors.invalidRequest),
92
+ '429': error(o.errors.rateLimited),
93
+ '503': error(o.errors.notConfigured)
94
+ }
95
+ }
96
+ },
97
+ [API_PATHS.portal]: {
98
+ post: {
99
+ operationId: 'openPortal',
100
+ summary: o.portal,
101
+ security: [{ apiKey: [] }],
102
+ responses: {
103
+ '200': { description: o.url, content: json(ref('Url')) },
104
+ '401': error(o.errors.unauthorized),
105
+ '409': error(o.errors.noCustomer),
106
+ '429': error(o.errors.rateLimited),
107
+ '503': error(o.errors.notConfigured)
108
+ }
109
+ }
110
+ }
111
+ },
112
+ components: {
113
+ schemas: {
114
+ Error: {
115
+ type: 'object',
116
+ required: ['error'],
117
+ properties: {
118
+ error: {
119
+ type: 'object',
120
+ required: ['code', 'message'],
121
+ properties: {
122
+ code: { type: 'string' },
123
+ message: { type: 'string' },
124
+ details: {}
125
+ }
126
+ }
127
+ }
128
+ },
129
+ Url: {
130
+ type: 'object',
131
+ required: ['url'],
132
+ properties: { url: { type: 'string', format: 'uri', description: o.url } }
133
+ },
134
+ Account: {
135
+ type: 'object',
136
+ required: ['id', 'email', 'email_verified', 'created_at'],
137
+ properties: {
138
+ id: { type: 'string', format: 'uuid' },
139
+ email: { type: 'string', format: 'email' },
140
+ email_verified: { type: 'boolean' },
141
+ created_at: { type: 'string', format: 'date-time' }
142
+ }
143
+ }
144
+ },
145
+ securitySchemes: {
146
+ apiKey: { type: 'http', scheme: 'bearer', description: o.apiKey }
147
+ }
148
+ }
149
+ };
150
+ }
151
+ /**
152
+ * `document` with the part of the baukasten. The product's own paths use its security scheme
153
+ * `apiKey` and its schema `Error`; a name both define is an error, not an override.
154
+ */
155
+ export function mergeOpenApi(document, part) {
156
+ const merge = (what, theirs, own) => {
157
+ const both = Object.keys(own ?? {}).filter((key) => key in theirs);
158
+ if (both.length > 0) {
159
+ throw new Error(`the OpenAPI document of the product defines ${what} of the baukasten: ${both.join(', ')}`);
160
+ }
161
+ return { ...theirs, ...own };
162
+ };
163
+ const components = document.components ?? {};
164
+ return {
165
+ ...document,
166
+ paths: merge('paths', part.paths, document.paths),
167
+ components: {
168
+ ...components,
169
+ schemas: merge('schemas', part.components.schemas, components.schemas),
170
+ securitySchemes: merge('security schemes', part.components.securitySchemes, components.securitySchemes)
171
+ }
172
+ };
173
+ }
@@ -0,0 +1,158 @@
1
+ import { type RequestEvent } from '@sveltejs/kit';
2
+ import type { Brand } from '../product.js';
3
+ import type { AccountData, ConfirmData, FrameData, LegalData, LoginData, LogoutData, ResetData, SignupData, VerifyData } from '../ui/data.js';
4
+ import { type Services } from './services.js';
5
+ type LoadEvent = {
6
+ locals: App.Locals;
7
+ url: URL;
8
+ };
9
+ /** The marks of the product as the frame shows them: the picture of a shared link at its whole address. */
10
+ export declare function frameBrand(brand: Brand | undefined, origin: string): FrameData['brand'];
11
+ export type Pages = ReturnType<typeof createPages>;
12
+ export declare function createPages(services: () => Services): {
13
+ layout: {
14
+ load: ({ locals, url }: LoadEvent) => {
15
+ frame: FrameData;
16
+ };
17
+ };
18
+ imprint: {
19
+ load: () => {
20
+ legal: LegalData;
21
+ };
22
+ };
23
+ privacy: {
24
+ load: () => {
25
+ legal: LegalData;
26
+ };
27
+ };
28
+ terms: {
29
+ load: () => {
30
+ legal: LegalData;
31
+ };
32
+ };
33
+ signup: {
34
+ load: ({ locals, url }: LoadEvent) => {
35
+ signup: SignupData;
36
+ };
37
+ actions: {
38
+ default: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
39
+ email: string;
40
+ error: string;
41
+ }>>;
42
+ };
43
+ };
44
+ login: {
45
+ load: ({ locals, url }: LoadEvent) => {
46
+ login: LoginData;
47
+ };
48
+ actions: {
49
+ default: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
50
+ email: string;
51
+ error: string;
52
+ }>>;
53
+ };
54
+ };
55
+ logout: {
56
+ load: ({ locals, url }: LoadEvent) => {
57
+ logout: LogoutData;
58
+ };
59
+ actions: {
60
+ default: ({ cookies }: RequestEvent) => Promise<never>;
61
+ };
62
+ };
63
+ forgotPassword: {
64
+ actions: {
65
+ default: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
66
+ email: string;
67
+ error: string;
68
+ }> | {
69
+ email: string;
70
+ sent: boolean;
71
+ }>;
72
+ };
73
+ };
74
+ resetPassword: {
75
+ load: ({ url }: LoadEvent) => Promise<{
76
+ reset: ResetData;
77
+ }>;
78
+ actions: {
79
+ default: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
80
+ error: string;
81
+ }>>;
82
+ };
83
+ };
84
+ /**
85
+ * The link of the mail opens a page with a button instead of confirming on GET, so that a mail
86
+ * scanner that opens links does not use it up. Confirming never logs into an account that has
87
+ * a password: whoever holds a mistyped address must not get in. An account from the API has
88
+ * none; it may set one here and is logged in.
89
+ */
90
+ verifyEmail: {
91
+ load: ({ locals, url }: LoadEvent) => Promise<{
92
+ verify: VerifyData;
93
+ }>;
94
+ actions: {
95
+ confirm: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
96
+ error: string;
97
+ }>>;
98
+ resend: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
99
+ error: string;
100
+ }> | {
101
+ resent: string;
102
+ }>;
103
+ };
104
+ };
105
+ confirmEmail: {
106
+ load: ({ url }: LoadEvent) => Promise<{
107
+ confirm: ConfirmData;
108
+ }>;
109
+ actions: {
110
+ default: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
111
+ error: string;
112
+ }>>;
113
+ };
114
+ };
115
+ account: {
116
+ load: (event: LoadEvent) => Promise<{
117
+ account: AccountData;
118
+ }>;
119
+ actions: {
120
+ createKey: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
121
+ action: "createKey";
122
+ error: string;
123
+ }> | {
124
+ action: "createKey";
125
+ key: string;
126
+ }>;
127
+ revokeKey: (event: RequestEvent) => Promise<{
128
+ action: "revokeKey";
129
+ }>;
130
+ changePassword: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
131
+ action: "changePassword";
132
+ error: string;
133
+ }> | {
134
+ action: "changePassword";
135
+ done: boolean;
136
+ }>;
137
+ changeEmail: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
138
+ action: "changeEmail";
139
+ email: string;
140
+ error: string;
141
+ }> | {
142
+ action: "changeEmail";
143
+ email: string;
144
+ sentTo: string;
145
+ }>;
146
+ /**
147
+ * Only a customer has a portal; opening it must not make one, which with the live key
148
+ * makes the account live.
149
+ */
150
+ portal: (event: RequestEvent) => Promise<never>;
151
+ delete: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
152
+ action: "delete";
153
+ error: string;
154
+ }>>;
155
+ };
156
+ };
157
+ };
158
+ export {};