franchising 0.0.0-stage → 0.1.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 (227) hide show
  1. package/LICENSE +61 -0
  2. package/README.md +88 -2
  3. package/dist/accounts-B4bnTXUd.js +242 -0
  4. package/dist/accounts-B4bnTXUd.js.map +1 -0
  5. package/dist/accounts-TyMPSHM0.cjs +313 -0
  6. package/dist/accounts-TyMPSHM0.cjs.map +1 -0
  7. package/dist/adapters-DM59AJfR.d.cts +216 -0
  8. package/dist/adapters-DM59AJfR.d.ts +216 -0
  9. package/dist/cli/template-assets/api/src/errors/codes.ts +17 -0
  10. package/dist/cli/template-assets/api/src/errors/index.ts +16 -0
  11. package/dist/cli/template-assets/api/src/filters/exception.ts +53 -0
  12. package/dist/cli/template-assets/api/src/main.ts +189 -0
  13. package/dist/cli/template-assets/api/src/modules/health/controller.ts +23 -0
  14. package/dist/cli/template-assets/api/src/modules/health/dto/response.dto.ts +23 -0
  15. package/dist/cli/template-assets/api/src/modules/health/module.ts +12 -0
  16. package/dist/cli/template-assets/api/src/modules/health/service.ts +54 -0
  17. package/dist/cli/template-assets/api/src/modules/messaging/module.ts +7 -0
  18. package/dist/cli/template-assets/api/src/modules/messaging/service.ts +74 -0
  19. package/dist/cli/template-assets/api/src/shared/exceptions.ts +40 -0
  20. package/dist/cli/template-assets/api/src/shared/response.ts +31 -0
  21. package/dist/cli/template-assets/api/src/telemetry.ts +59 -0
  22. package/dist/cli/template-assets/api/src/types.ts +8 -0
  23. package/dist/cli/template-assets/cloudflare/cache.service.ts +23 -0
  24. package/dist/cli/template-assets/cloudflare/queue.service.ts +22 -0
  25. package/dist/cli/template-assets/cloudflare/worker.ts +33 -0
  26. package/dist/cli/template-assets/packages/jobs/src/index.ts +49 -0
  27. package/dist/cli/template-assets/packages/queue-runtime/src/index.ts +54 -0
  28. package/dist/cli/template-assets/root/dot-dockerignore +11 -0
  29. package/dist/cli/template-assets/root/dot-editorconfig +13 -0
  30. package/dist/cli/template-assets/root/dot-oxfmtrc.json +9 -0
  31. package/dist/cli/template-assets/root/dot-oxlintrc.json +47 -0
  32. package/dist/cli/template-assets/root/lefthook.yml +18 -0
  33. package/dist/cli/template-assets/web/postcss.config.mjs +9 -0
  34. package/dist/cli/template-assets/web/src/app/(app)/dashboard/page.tsx +5 -0
  35. package/dist/cli/template-assets/web/src/app/(app)/layout.tsx +25 -0
  36. package/dist/cli/template-assets/web/src/app/(auth)/login/page.tsx +75 -0
  37. package/dist/cli/template-assets/web/src/app/globals.css +48 -0
  38. package/dist/cli/template-assets/web/src/app/layout.tsx +30 -0
  39. package/dist/cli/template-assets/web/src/app/page.tsx +20 -0
  40. package/dist/cli/template-assets/web/src/components/overview/overview-panel.tsx +27 -0
  41. package/dist/cli/template-assets/web/src/components/shell/app-shell.tsx +37 -0
  42. package/dist/cli/template-assets/web/src/components/shell/providers.tsx +22 -0
  43. package/dist/cli/template-assets/web/src/lib/api-client.ts +57 -0
  44. package/dist/cli/template-assets/web/src/lib/auth-client.ts +15 -0
  45. package/dist/cli/template-assets/web/src/lib/server-auth.ts +38 -0
  46. package/dist/cli/template-assets/web/src/types/api.ts +18 -0
  47. package/dist/cli/template-assets/worker/src/app.module.ts +5 -0
  48. package/dist/cli/template-assets/worker/src/env.ts +8 -0
  49. package/dist/cli/template-assets/worker/src/main.ts +25 -0
  50. package/dist/cli/template-assets/worker/src/modules/queue/config.ts +16 -0
  51. package/dist/cli/template-assets/worker/src/modules/queue/module.ts +11 -0
  52. package/dist/cli/template-assets/worker/src/modules/queue/processor.ts +105 -0
  53. package/dist/cli/template-assets/worker/src/modules/queue/repository.ts +16 -0
  54. package/dist/cli/template-assets/worker/src/modules/queue/retry.ts +17 -0
  55. package/dist/cli/template-assets/worker/test/retry.test.ts.tpl +12 -0
  56. package/dist/cli/template-assets/worker-messaging/jobs-messaging.ts +12 -0
  57. package/dist/cli/template-assets/worker-messaging/messaging-api-service.ts +39 -0
  58. package/dist/cli/template-assets/worker-messaging/src/env.ts +14 -0
  59. package/dist/cli/template-assets/worker-messaging/src/modules/messaging/service.ts +59 -0
  60. package/dist/cli/template-assets/worker-messaging/src/modules/queue/module.ts +8 -0
  61. package/dist/cli/template-assets/worker-messaging/src/modules/queue/processor.ts +113 -0
  62. package/dist/cli.js +1218 -0
  63. package/dist/cn-BVOnrSza.js +1 -0
  64. package/dist/constants-C4iP0--i.js +38 -0
  65. package/dist/constants-C4iP0--i.js.map +1 -0
  66. package/dist/constants-rCR-LNSN.cjs +91 -0
  67. package/dist/constants-rCR-LNSN.cjs.map +1 -0
  68. package/dist/decorate-BR5FVX5x.js +14 -0
  69. package/dist/decorate-R-oqksAh.cjs +25 -0
  70. package/dist/decorateParam-BFJPEGKJ.cjs +13 -0
  71. package/dist/decorateParam-CKE7_J1s.js +8 -0
  72. package/dist/define-adapter-Cc0QrfKt.cjs +16 -0
  73. package/dist/define-adapter-Cc0QrfKt.cjs.map +1 -0
  74. package/dist/define-adapter-DRcXno3j.js +11 -0
  75. package/dist/define-adapter-DRcXno3j.js.map +1 -0
  76. package/dist/dispatcher-BsD7cO2w.cjs +84 -0
  77. package/dist/dispatcher-BsD7cO2w.cjs.map +1 -0
  78. package/dist/dispatcher-DA_l1Vkv.js +73 -0
  79. package/dist/dispatcher-DA_l1Vkv.js.map +1 -0
  80. package/dist/errors-DxHoXrLd.d.cts +46 -0
  81. package/dist/errors-DxHoXrLd.d.ts +46 -0
  82. package/dist/http/index.cjs +440 -0
  83. package/dist/http/index.cjs.map +1 -0
  84. package/dist/http/index.d.cts +257 -0
  85. package/dist/http/index.d.ts +257 -0
  86. package/dist/http/index.js +400 -0
  87. package/dist/http/index.js.map +1 -0
  88. package/dist/http/swagger.cjs +122 -0
  89. package/dist/http/swagger.cjs.map +1 -0
  90. package/dist/http/swagger.d.cts +59 -0
  91. package/dist/http/swagger.d.ts +59 -0
  92. package/dist/http/swagger.js +117 -0
  93. package/dist/http/swagger.js.map +1 -0
  94. package/dist/index-B3UOHsA9.d.ts +679 -0
  95. package/dist/index-Bdl0AiNM.d.ts +1262 -0
  96. package/dist/index-By8b4ksT.d.ts +25 -0
  97. package/dist/index-C1KmT8dQ.d.ts +174 -0
  98. package/dist/index-CYT1PFzo.d.cts +679 -0
  99. package/dist/index-Cj-10Q5F.d.cts +174 -0
  100. package/dist/index-DDSaLjXV.d.cts +25 -0
  101. package/dist/index-FTrYdHfq.d.cts +1262 -0
  102. package/dist/index.cjs +1 -0
  103. package/dist/index.d.cts +4 -0
  104. package/dist/index.d.ts +4 -0
  105. package/dist/index.js +1 -0
  106. package/dist/label-BqmJoVE-.cjs +1 -0
  107. package/dist/label-XeChe1Bu.js +1 -0
  108. package/dist/messaging/index.cjs +1 -0
  109. package/dist/messaging/index.d.cts +1775 -0
  110. package/dist/messaging/index.d.ts +1775 -0
  111. package/dist/messaging/index.js +1 -0
  112. package/dist/misc-BpM_lMTx.js +1 -0
  113. package/dist/misc-DkqJOm1V.cjs +1 -0
  114. package/dist/operational-CnxdBwVG.d.cts +13 -0
  115. package/dist/operational-CnxdBwVG.d.ts +13 -0
  116. package/dist/redaction-DhuHTlHA.js +124 -0
  117. package/dist/redaction-DhuHTlHA.js.map +1 -0
  118. package/dist/redaction-uRIQbTwZ.cjs +171 -0
  119. package/dist/redaction-uRIQbTwZ.cjs.map +1 -0
  120. package/dist/rolldown-runtime-auK_WOaK.cjs +1 -0
  121. package/dist/rolldown-runtime-xuxB8TGW.cjs +32 -0
  122. package/dist/runtime-C95UYYLb.cjs +111 -0
  123. package/dist/runtime-C95UYYLb.cjs.map +1 -0
  124. package/dist/runtime-DG2oBFYw.js +88 -0
  125. package/dist/runtime-DG2oBFYw.js.map +1 -0
  126. package/dist/skills-C1uwr9Pp.js +4 -0
  127. package/dist/skills-DuE-XnBp.js +1 -0
  128. package/dist/sso/client.cjs +37 -0
  129. package/dist/sso/client.cjs.map +1 -0
  130. package/dist/sso/client.d.cts +90 -0
  131. package/dist/sso/client.d.ts +90 -0
  132. package/dist/sso/client.js +36 -0
  133. package/dist/sso/client.js.map +1 -0
  134. package/dist/sso/index.cjs +833 -0
  135. package/dist/sso/index.cjs.map +1 -0
  136. package/dist/sso/index.d.cts +3 -0
  137. package/dist/sso/index.d.ts +3 -0
  138. package/dist/sso/index.js +821 -0
  139. package/dist/sso/index.js.map +1 -0
  140. package/dist/sso/nestjs.cjs +169 -0
  141. package/dist/sso/nestjs.cjs.map +1 -0
  142. package/dist/sso/nestjs.d.cts +92 -0
  143. package/dist/sso/nestjs.d.ts +92 -0
  144. package/dist/sso/nestjs.js +151 -0
  145. package/dist/sso/nestjs.js.map +1 -0
  146. package/dist/sso/resource.cjs +124 -0
  147. package/dist/sso/resource.cjs.map +1 -0
  148. package/dist/sso/resource.d.cts +3 -0
  149. package/dist/sso/resource.d.ts +3 -0
  150. package/dist/sso/resource.js +114 -0
  151. package/dist/sso/resource.js.map +1 -0
  152. package/dist/status-CRvlFPIs.js +13 -0
  153. package/dist/status-CRvlFPIs.js.map +1 -0
  154. package/dist/status-DtK6OHtj.cjs +24 -0
  155. package/dist/status-DtK6OHtj.cjs.map +1 -0
  156. package/dist/team-CJVAg4HH.d.cts +157 -0
  157. package/dist/team-CJVAg4HH.d.ts +157 -0
  158. package/dist/telemetry/adapters.cjs +6 -0
  159. package/dist/telemetry/adapters.d.cts +3 -0
  160. package/dist/telemetry/adapters.d.ts +3 -0
  161. package/dist/telemetry/adapters.js +4 -0
  162. package/dist/telemetry/betterstack.cjs +74 -0
  163. package/dist/telemetry/betterstack.cjs.map +1 -0
  164. package/dist/telemetry/betterstack.d.cts +12 -0
  165. package/dist/telemetry/betterstack.d.ts +12 -0
  166. package/dist/telemetry/betterstack.js +71 -0
  167. package/dist/telemetry/betterstack.js.map +1 -0
  168. package/dist/telemetry/index.cjs +1237 -0
  169. package/dist/telemetry/index.cjs.map +1 -0
  170. package/dist/telemetry/index.d.cts +114 -0
  171. package/dist/telemetry/index.d.ts +114 -0
  172. package/dist/telemetry/index.js +1205 -0
  173. package/dist/telemetry/index.js.map +1 -0
  174. package/dist/telemetry/posthog.cjs +72 -0
  175. package/dist/telemetry/posthog.cjs.map +1 -0
  176. package/dist/telemetry/posthog.d.cts +10 -0
  177. package/dist/telemetry/posthog.d.ts +10 -0
  178. package/dist/telemetry/posthog.js +71 -0
  179. package/dist/telemetry/posthog.js.map +1 -0
  180. package/dist/telemetry/register.cjs +6 -0
  181. package/dist/telemetry/register.d.cts +14 -0
  182. package/dist/telemetry/register.d.ts +14 -0
  183. package/dist/telemetry/register.js +3 -0
  184. package/dist/telemetry/testing.cjs +54 -0
  185. package/dist/telemetry/testing.cjs.map +1 -0
  186. package/dist/telemetry/testing.d.cts +15 -0
  187. package/dist/telemetry/testing.d.ts +15 -0
  188. package/dist/telemetry/testing.js +52 -0
  189. package/dist/telemetry/testing.js.map +1 -0
  190. package/dist/telemetry.mock-BSsx7L6S.cjs +45 -0
  191. package/dist/telemetry.mock-BSsx7L6S.cjs.map +1 -0
  192. package/dist/telemetry.mock-BZRpy63c.js +40 -0
  193. package/dist/telemetry.mock-BZRpy63c.js.map +1 -0
  194. package/dist/telemetry.mock-C1wXuf-M.d.cts +4 -0
  195. package/dist/telemetry.mock-CdaxofJ7.d.ts +4 -0
  196. package/dist/ui/chart.cjs +6 -0
  197. package/dist/ui/chart.d.cts +34 -0
  198. package/dist/ui/chart.d.ts +34 -0
  199. package/dist/ui/chart.js +6 -0
  200. package/dist/ui/form.cjs +1 -0
  201. package/dist/ui/form.d.cts +23 -0
  202. package/dist/ui/form.d.ts +23 -0
  203. package/dist/ui/form.js +1 -0
  204. package/dist/ui/hooks.cjs +1 -0
  205. package/dist/ui/hooks.d.cts +66 -0
  206. package/dist/ui/hooks.d.ts +66 -0
  207. package/dist/ui/hooks.js +1 -0
  208. package/dist/ui/index.cjs +1 -0
  209. package/dist/ui/index.d.cts +3 -0
  210. package/dist/ui/index.d.ts +3 -0
  211. package/dist/ui/index.js +1 -0
  212. package/dist/ui/styles.css +2 -0
  213. package/dist/ui/utils.cjs +1 -0
  214. package/dist/ui/utils.d.cts +199 -0
  215. package/dist/ui/utils.d.ts +199 -0
  216. package/dist/ui/utils.js +1 -0
  217. package/dist/use-mobile-BbeIMRgE.cjs +1 -0
  218. package/dist/use-mobile-Cdd4Lp7p.js +1 -0
  219. package/dist/use-mobile-ecpyXWz3.d.cts +10 -0
  220. package/dist/use-mobile-ecpyXWz3.d.ts +10 -0
  221. package/dist/verifier-BIBtPCVi.cjs +119 -0
  222. package/dist/verifier-BIBtPCVi.cjs.map +1 -0
  223. package/dist/verifier-DNdy5Ynw.js +90 -0
  224. package/dist/verifier-DNdy5Ynw.js.map +1 -0
  225. package/dist/version-CPunTYCY.js +1 -0
  226. package/dist/version-CfUi3iAV.cjs +1 -0
  227. package/package.json +523 -5
@@ -0,0 +1,124 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_verifier = require("../verifier-BIBtPCVi.cjs");
3
+ const require_accounts = require("../accounts-TyMPSHM0.cjs");
4
+ const require_constants = require("../constants-rCR-LNSN.cjs");
5
+ let zod = require("zod");
6
+
7
+ // src/modules/sso/resource/preferences.ts
8
+ function createPreferences(options = {}) {
9
+ return require_accounts.createAccountsApi({
10
+ clientId: "",
11
+ clientSecret: "",
12
+ ...options
13
+ }).preferences;
14
+ }
15
+
16
+ // src/modules/sso/resource/exchange/error.ts
17
+ var TokenExchangeError = class extends require_accounts.RockfellerError {
18
+ name = "TokenExchangeError";
19
+ };
20
+
21
+ // src/modules/sso/resource/exchange/response.ts
22
+ const successBody = zod.z.object({
23
+ access_token: zod.z.string().min(1),
24
+ expires_in: zod.z.number().positive()
25
+ });
26
+ const failureBody = zod.z.object({
27
+ error: zod.z.string().min(1),
28
+ error_description: zod.z.string().optional()
29
+ });
30
+ async function readTokenResponse(response) {
31
+ const body = await response.json().catch(() => null);
32
+ if (!response.ok) {
33
+ const failure = failureBody.safeParse(body).data;
34
+ throw new TokenExchangeError(failure?.error ?? "server_error", response.status, failure?.error_description ?? "O Accounts recusou a troca de token.");
35
+ }
36
+ const success = successBody.safeParse(body).data;
37
+ if (!success) throw new TokenExchangeError("server_error", response.status, "O Accounts respondeu à troca de token de forma inesperada.");
38
+ return {
39
+ accessToken: success.access_token,
40
+ expiresAt: new Date(Date.now() + success.expires_in * 1e3)
41
+ };
42
+ }
43
+
44
+ // src/modules/sso/resource/exchange/exchanger.ts
45
+ const GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
46
+ const ACCESS_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
47
+ const REUSE_MARGIN_MS = 6e4;
48
+ const TIMEOUT_MS = 1e4;
49
+ function invalidRequest(message) {
50
+ return new TokenExchangeError("invalid_request", 400, message);
51
+ }
52
+ async function sha256Hex(value) {
53
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
54
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
55
+ }
56
+ function isReusable(token) {
57
+ return token.expiresAt.getTime() - REUSE_MARGIN_MS > Date.now();
58
+ }
59
+ function createTokenExchanger(options) {
60
+ const tokenUrl = require_constants.accountsUrls(require_constants.normalizeIssuer(options.issuer)).token;
61
+ const credentials = btoa(`${encodeURIComponent(options.clientId)}:${encodeURIComponent(options.clientSecret)}`);
62
+ const cache = /* @__PURE__ */ new Map();
63
+ const inFlight = /* @__PURE__ */ new Map();
64
+ async function requestToken(form) {
65
+ let response;
66
+ try {
67
+ response = await fetch(tokenUrl, {
68
+ method: "POST",
69
+ headers: { authorization: `Basic ${credentials}` },
70
+ body: form,
71
+ signal: AbortSignal.timeout(TIMEOUT_MS)
72
+ });
73
+ } catch {
74
+ throw new TokenExchangeError("network_error", 502, "Não foi possível falar com o Accounts.");
75
+ }
76
+ return readTokenResponse(response);
77
+ }
78
+ function remember(key, token) {
79
+ for (const [storedKey, stored] of cache) if (!isReusable(stored)) cache.delete(storedKey);
80
+ cache.set(key, token);
81
+ }
82
+ return { async exchange(input) {
83
+ const subjectToken = require_verifier.bearerToken(input.subjectToken);
84
+ const resource = input.resource.trim();
85
+ const scope = input.scope?.trim() ?? "";
86
+ if (!subjectToken) throw invalidRequest("Falta o token da pessoa (`subjectToken`).");
87
+ if (!resource) throw invalidRequest("Falta o recurso de destino (`resource`).");
88
+ const key = JSON.stringify([
89
+ await sha256Hex(subjectToken),
90
+ resource,
91
+ scope
92
+ ]);
93
+ const cached = cache.get(key);
94
+ if (cached && isReusable(cached)) return cached;
95
+ let pending = inFlight.get(key);
96
+ if (!pending) {
97
+ const form = new URLSearchParams({
98
+ grant_type: GRANT_TYPE,
99
+ subject_token: subjectToken,
100
+ subject_token_type: ACCESS_TOKEN_TYPE,
101
+ resource
102
+ });
103
+ if (scope) form.set("scope", scope);
104
+ pending = requestToken(form).then((token) => {
105
+ remember(key, token);
106
+ return token;
107
+ }).finally(() => inFlight.delete(key));
108
+ inFlight.set(key, pending);
109
+ }
110
+ return pending;
111
+ } };
112
+ }
113
+
114
+ exports.InvalidTokenError = require_verifier.InvalidTokenError;
115
+ exports.RockfellerError = require_accounts.RockfellerError;
116
+ exports.RockfellerErrorCode = require_accounts.RockfellerErrorCode;
117
+ exports.TokenExchangeError = TokenExchangeError;
118
+ exports.assertWritable = require_verifier.assertWritable;
119
+ exports.createAuthorization = require_verifier.createAuthorization;
120
+ exports.createPreferences = createPreferences;
121
+ exports.createTokenExchanger = createTokenExchanger;
122
+ exports.createTokenVerifier = require_verifier.createTokenVerifier;
123
+ exports.isRockfellerError = require_accounts.isRockfellerError;
124
+ //# sourceMappingURL=resource.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.cjs","names":["createAccountsApi","RockfellerError","z","accountsUrls","normalizeIssuer","bearerToken"],"sources":["../../src/modules/sso/resource/preferences.ts","../../src/modules/sso/resource/exchange/error.ts","../../src/modules/sso/resource/exchange/response.ts","../../src/modules/sso/resource/exchange/exchanger.ts"],"mappings":";;;;;;;AAgBA,SA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IAAI,GAAG;EAE5B,IAAI,UAAU,WAAW,MAAM,GAAG,OAAO;EAEzC,IAAI,UAAU,SAAS,IAAI,GAAG;EAE9B,IAAI,CAAC,SAAS;GACb,MAAM,OAAO,IAAI,gBAAgB;IAChC,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB;GACD,CAAC;GAED,IAAI,OAAO,KAAK,IAAI,SAAS,KAAK;GAElC,UAAU,aAAa,IAAI,CAAC,CAC1B,MAAM,UAAU;IAChB,SAAS,KAAK,KAAK;IAEnB,OAAO;GACR,CAAC,CAAC,CACD,cAAc,SAAS,OAAO,GAAG,CAAC;GACpC,SAAS,IAAI,KAAK,OAAO;EAC1B;EAEA,OAAO;CACR,EACD;AACD"}
@@ -0,0 +1,3 @@
1
+ import { C as RockfellerError, S as Timezone, T as RockfellerErrorCode, _ as HourCycle, a as TeamMembersQuery, b as ReducedMotion, c as TeamRoleOrigin, d as SchoolList, f as SchoolMembership, g as Contrast, h as SchoolType, i as TeamMember, l as Permission, m as SchoolRef, n as TeamInvitation, o as TeamRole, p as SchoolPermissions, r as TeamInvitationInput, s as TeamRoleKey, t as Page, u as School, v as Preferences, w as isRockfellerError, x as Theme, y as PreferencesPatch } from "../team-CJVAg4HH.cjs";
2
+ import { _ as assertWritable, a as TokenExchangerOptions, c as Preferences$1, d as Authorization, f as AuthorizationOptions, g as InvalidTokenError, h as VerifiedToken, i as TokenExchanger, l as PreferencesOptions, m as TokenVerifierOptions, n as ExchangedToken, o as TokenExchangeError, p as TokenVerifier, r as TokenExchangeInput, s as createPreferences, t as createTokenExchanger, u as createAuthorization, v as createTokenVerifier } from "../index-Cj-10Q5F.cjs";
3
+ export { type Authorization, type AuthorizationOptions, type Contrast, type ExchangedToken, type HourCycle, InvalidTokenError, type Page, type Permission, type Preferences, type Preferences$1 as PreferencesClient, type PreferencesOptions, type PreferencesPatch, type ReducedMotion, RockfellerError, RockfellerErrorCode, type School, type SchoolList, type SchoolMembership, type SchoolPermissions, type SchoolRef, type SchoolType, type TeamInvitation, type TeamInvitationInput, type TeamMember, type TeamMembersQuery, type TeamRole, type TeamRoleKey, type TeamRoleOrigin, type Theme, type Timezone, TokenExchangeError, type TokenExchangeInput, type TokenExchanger, type TokenExchangerOptions, type TokenVerifier, type TokenVerifierOptions, type VerifiedToken, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
@@ -0,0 +1,3 @@
1
+ import { C as RockfellerError, S as Timezone, T as RockfellerErrorCode, _ as HourCycle, a as TeamMembersQuery, b as ReducedMotion, c as TeamRoleOrigin, d as SchoolList, f as SchoolMembership, g as Contrast, h as SchoolType, i as TeamMember, l as Permission, m as SchoolRef, n as TeamInvitation, o as TeamRole, p as SchoolPermissions, r as TeamInvitationInput, s as TeamRoleKey, t as Page, u as School, v as Preferences, w as isRockfellerError, x as Theme, y as PreferencesPatch } from "../team-CJVAg4HH.js";
2
+ import { _ as assertWritable, a as TokenExchangerOptions, c as Preferences$1, d as Authorization, f as AuthorizationOptions, g as InvalidTokenError, h as VerifiedToken, i as TokenExchanger, l as PreferencesOptions, m as TokenVerifierOptions, n as ExchangedToken, o as TokenExchangeError, p as TokenVerifier, r as TokenExchangeInput, s as createPreferences, t as createTokenExchanger, u as createAuthorization, v as createTokenVerifier } from "../index-C1KmT8dQ.js";
3
+ export { type Authorization, type AuthorizationOptions, type Contrast, type ExchangedToken, type HourCycle, InvalidTokenError, type Page, type Permission, type Preferences, type Preferences$1 as PreferencesClient, type PreferencesOptions, type PreferencesPatch, type ReducedMotion, RockfellerError, RockfellerErrorCode, type School, type SchoolList, type SchoolMembership, type SchoolPermissions, type SchoolRef, type SchoolType, type TeamInvitation, type TeamInvitationInput, type TeamMember, type TeamMembersQuery, type TeamRole, type TeamRoleKey, type TeamRoleOrigin, type Theme, type Timezone, TokenExchangeError, type TokenExchangeInput, type TokenExchanger, type TokenExchangerOptions, type TokenVerifier, type TokenVerifierOptions, type VerifiedToken, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
@@ -0,0 +1,114 @@
1
+ import { a as createAuthorization, i as bearerToken, n as assertWritable, r as createTokenVerifier, t as InvalidTokenError } from "../verifier-DNdy5Ynw.js";
2
+ import { f as RockfellerErrorCode, i as isRockfellerError, r as RockfellerError, t as createAccountsApi } from "../accounts-B4bnTXUd.js";
3
+ import { c as accountsUrls, l as normalizeIssuer } from "../constants-C4iP0--i.js";
4
+ import { z } from "zod";
5
+
6
+ // src/modules/sso/resource/preferences.ts
7
+ function createPreferences(options = {}) {
8
+ return createAccountsApi({
9
+ clientId: "",
10
+ clientSecret: "",
11
+ ...options
12
+ }).preferences;
13
+ }
14
+
15
+ // src/modules/sso/resource/exchange/error.ts
16
+ var TokenExchangeError = class extends RockfellerError {
17
+ name = "TokenExchangeError";
18
+ };
19
+
20
+ // src/modules/sso/resource/exchange/response.ts
21
+ const successBody = z.object({
22
+ access_token: z.string().min(1),
23
+ expires_in: z.number().positive()
24
+ });
25
+ const failureBody = z.object({
26
+ error: z.string().min(1),
27
+ error_description: z.string().optional()
28
+ });
29
+ async function readTokenResponse(response) {
30
+ const body = await response.json().catch(() => null);
31
+ if (!response.ok) {
32
+ const failure = failureBody.safeParse(body).data;
33
+ throw new TokenExchangeError(failure?.error ?? "server_error", response.status, failure?.error_description ?? "O Accounts recusou a troca de token.");
34
+ }
35
+ const success = successBody.safeParse(body).data;
36
+ if (!success) throw new TokenExchangeError("server_error", response.status, "O Accounts respondeu à troca de token de forma inesperada.");
37
+ return {
38
+ accessToken: success.access_token,
39
+ expiresAt: new Date(Date.now() + success.expires_in * 1e3)
40
+ };
41
+ }
42
+
43
+ // src/modules/sso/resource/exchange/exchanger.ts
44
+ const GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
45
+ const ACCESS_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
46
+ const REUSE_MARGIN_MS = 6e4;
47
+ const TIMEOUT_MS = 1e4;
48
+ function invalidRequest(message) {
49
+ return new TokenExchangeError("invalid_request", 400, message);
50
+ }
51
+ async function sha256Hex(value) {
52
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
53
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
54
+ }
55
+ function isReusable(token) {
56
+ return token.expiresAt.getTime() - REUSE_MARGIN_MS > Date.now();
57
+ }
58
+ function createTokenExchanger(options) {
59
+ const tokenUrl = accountsUrls(normalizeIssuer(options.issuer)).token;
60
+ const credentials = btoa(`${encodeURIComponent(options.clientId)}:${encodeURIComponent(options.clientSecret)}`);
61
+ const cache = /* @__PURE__ */ new Map();
62
+ const inFlight = /* @__PURE__ */ new Map();
63
+ async function requestToken(form) {
64
+ let response;
65
+ try {
66
+ response = await fetch(tokenUrl, {
67
+ method: "POST",
68
+ headers: { authorization: `Basic ${credentials}` },
69
+ body: form,
70
+ signal: AbortSignal.timeout(TIMEOUT_MS)
71
+ });
72
+ } catch {
73
+ throw new TokenExchangeError("network_error", 502, "Não foi possível falar com o Accounts.");
74
+ }
75
+ return readTokenResponse(response);
76
+ }
77
+ function remember(key, token) {
78
+ for (const [storedKey, stored] of cache) if (!isReusable(stored)) cache.delete(storedKey);
79
+ cache.set(key, token);
80
+ }
81
+ return { async exchange(input) {
82
+ const subjectToken = bearerToken(input.subjectToken);
83
+ const resource = input.resource.trim();
84
+ const scope = input.scope?.trim() ?? "";
85
+ if (!subjectToken) throw invalidRequest("Falta o token da pessoa (`subjectToken`).");
86
+ if (!resource) throw invalidRequest("Falta o recurso de destino (`resource`).");
87
+ const key = JSON.stringify([
88
+ await sha256Hex(subjectToken),
89
+ resource,
90
+ scope
91
+ ]);
92
+ const cached = cache.get(key);
93
+ if (cached && isReusable(cached)) return cached;
94
+ let pending = inFlight.get(key);
95
+ if (!pending) {
96
+ const form = new URLSearchParams({
97
+ grant_type: GRANT_TYPE,
98
+ subject_token: subjectToken,
99
+ subject_token_type: ACCESS_TOKEN_TYPE,
100
+ resource
101
+ });
102
+ if (scope) form.set("scope", scope);
103
+ pending = requestToken(form).then((token) => {
104
+ remember(key, token);
105
+ return token;
106
+ }).finally(() => inFlight.delete(key));
107
+ inFlight.set(key, pending);
108
+ }
109
+ return pending;
110
+ } };
111
+ }
112
+
113
+ export { InvalidTokenError, RockfellerError, RockfellerErrorCode, TokenExchangeError, assertWritable, createAuthorization, createPreferences, createTokenExchanger, createTokenVerifier, isRockfellerError };
114
+ //# sourceMappingURL=resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.js","names":[],"sources":["../../src/modules/sso/resource/preferences.ts","../../src/modules/sso/resource/exchange/error.ts","../../src/modules/sso/resource/exchange/response.ts","../../src/modules/sso/resource/exchange/exchanger.ts"],"mappings":";;;;;;AAgBA,SAAgB,kBAAkB,UAA8B,CAAC,GAAG;CAEnE,OAAO,kBAAkB;EACxB,UAAU;EACV,cAAc;EACd,GAAG;CACJ,CAAC,CAAC,CAAC;AACJ;;;AChBA,IAAa,qBAAb,cAAwC,gBAAgB;CACvD,AAAkB,OAAe;AAClC;;;ACJA,MAAM,cAAc,EAAE,OAAO;CAC5B,cAAc,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC9B,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;AACjC,CAAC;AAED,MAAM,cAAc,EAAE,OAAO;CAC5B,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACvB,mBAAmB,EAAE,OAAO,CAAC,CAAC,SAAS;AACxC,CAAC;AAGD,eAAsB,kBACrB,UAC0B;CAC1B,MAAM,OAAgB,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,IAAI;CAE5D,IAAI,CAAC,SAAS,IAAI;EACjB,MAAM,UAAU,YAAY,UAAU,IAAI,CAAC,CAAC;EAE5C,MAAM,IAAI,mBACT,SAAS,SAAS,gBAClB,SAAS,QACT,SAAS,qBACR,sCACF;CACD;CAEA,MAAM,UAAU,YAAY,UAAU,IAAI,CAAC,CAAC;CAE5C,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AC3D,KAAK,MAAM,CAAC,WAAW,WAAW,OACjC,IAAI,CAAC,WAAW,MAAM,GAAG,MAAM,OAAO,SAAS;EAEhD,MAAM,IAAI,KAAK,KAAK;CACrB;CAEA,OAAO,EAEN,MAAM,SAAS,OAAoD;EAClE,MAAM,eAAe,YAAY,MAAM,YAAY;EACnD,MAAM,WAAW,MAAM,SAAS,KAAK;EACrC,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK;EAErC,IAAI,CAAC,cACJ,MAAM,eACL,2CACD;EAED,IAAI,CAAC,UACJ,MAAM,eACL,0CACD;EAED,MAAM,MAAM,KAAK,UAAU;GAC1B,MAAM,UAAU,YAAY;GAC5B;GACA;EACD,CAAC;EACD,MAAM,SAAS,MAAM,IAAI,GAAG;EAE5B,IAAI,UAAU,WAAW,MAAM,GAAG,OAAO;EAEzC,IAAI,UAAU,SAAS,IAAI,GAAG;EAE9B,IAAI,CAAC,SAAS;GACb,MAAM,OAAO,IAAI,gBAAgB;IAChC,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB;GACD,CAAC;GAED,IAAI,OAAO,KAAK,IAAI,SAAS,KAAK;GAElC,UAAU,aAAa,IAAI,CAAC,CAC1B,MAAM,UAAU;IAChB,SAAS,KAAK,KAAK;IAEnB,OAAO;GACR,CAAC,CAAC,CACD,cAAc,SAAS,OAAO,GAAG,CAAC;GACpC,SAAS,IAAI,KAAK,OAAO;EAC1B;EAEA,OAAO;CACR,EACD;AACD"}
@@ -0,0 +1,13 @@
1
+ // src/modules/http/shared/status.ts
2
+ const MIN_ERROR_STATUS = 400;
3
+ const MAX_ERROR_STATUS = 599;
4
+ function isErrorStatus(value) {
5
+ return typeof value === "number" && Number.isInteger(value) && value >= 400 && value <= 599;
6
+ }
7
+ function assertErrorStatus(value, label) {
8
+ if (!isErrorStatus(value)) throw new TypeError(`${label}: status must be an integer from ${400} to ${599}, got ${String(value)}.`);
9
+ return value;
10
+ }
11
+
12
+ export { isErrorStatus as n, assertErrorStatus as t };
13
+ //# sourceMappingURL=status-CRvlFPIs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-CRvlFPIs.js","names":[],"sources":["../src/modules/http/shared/status.ts"],"mappings":";AAAA,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAGhC,SAAgB,cAAc,OAAiC;CAC9D,OACC,OAAO,UAAU,YACjB,OAAO,UAAU,KAAK,KACtB,gBACA;AAEF;AAGA,SAAgB,kBAAkB,OAAgB,OAAuB;CACxE,IAAI,CAAC,cAAc,KAAK,GACvB,MAAM,IAAI,UACT,GAAG,MAAM,uCAAoD,UAAuB,QAAQ,OAAO,KAAK,EAAE,EAC3G;CAED,OAAO;AACR"}
@@ -0,0 +1,24 @@
1
+ // src/modules/http/shared/status.ts
2
+ const MIN_ERROR_STATUS = 400;
3
+ const MAX_ERROR_STATUS = 599;
4
+ function isErrorStatus(value) {
5
+ return typeof value === "number" && Number.isInteger(value) && value >= 400 && value <= 599;
6
+ }
7
+ function assertErrorStatus(value, label) {
8
+ if (!isErrorStatus(value)) throw new TypeError(`${label}: status must be an integer from ${400} to ${599}, got ${String(value)}.`);
9
+ return value;
10
+ }
11
+
12
+ Object.defineProperty(exports, "assertErrorStatus", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return assertErrorStatus;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "isErrorStatus", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return isErrorStatus;
22
+ }
23
+ });
24
+ //# sourceMappingURL=status-DtK6OHtj.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-DtK6OHtj.cjs","names":[],"sources":["../src/modules/http/shared/status.ts"],"mappings":";AAAA,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAGhC,SAAgB,cAAc,OAAiC;CAC9D,OACC,OAAO,UAAU,YACjB,OAAO,UAAU,KAAK,KACtB,gBACA;AAEF;AAGA,SAAgB,kBAAkB,OAAgB,OAAuB;CACxE,IAAI,CAAC,cAAc,KAAK,GACvB,MAAM,IAAI,UACT,GAAG,MAAM,uCAAoD,UAAuB,QAAQ,OAAO,KAAK,EAAE,EAC3G;CAED,OAAO;AACR"}
@@ -0,0 +1,157 @@
1
+ /** Códigos próprios do plugin; os do Accounts passam adiante como vieram. */
2
+ declare const RockfellerErrorCode: {
3
+ /** A pessoa não entrou pela Conta Rockfeller (sem conta `rockfeller`). */
4
+ readonly NOT_CONNECTED: "NOT_CONNECTED";
5
+ /** A gestão de equipe ainda não foi vinculada (`team.connect`). */
6
+ readonly TEAM_NOT_CONNECTED: "TEAM_NOT_CONNECTED";
7
+ /** `team: true` não foi ligado no plugin. */
8
+ readonly TEAM_NOT_ENABLED: "TEAM_NOT_ENABLED";
9
+ /** `api` não foi configurado no plugin. */
10
+ readonly API_NOT_CONFIGURED: "API_NOT_CONFIGURED";
11
+ /** Login por e-mail e senha desligado (`allowLocalSignIn`). */
12
+ readonly LOCAL_SIGN_IN_DISABLED: "LOCAL_SIGN_IN_DISABLED";
13
+ /** Sem a permissão pedida na escola. */
14
+ readonly FORBIDDEN: "FORBIDDEN";
15
+ /** Token ausente, inválido ou expirado. */
16
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
17
+ /** Token trocado (`act`) por um cliente que a API não aceita em nome da pessoa. */
18
+ readonly UNTRUSTED_ACTOR: "UNTRUSTED_ACTOR";
19
+ /** Token de impersonação (um admin vendo como a pessoa) numa API que não o aceita. */
20
+ readonly IMPERSONATION_NOT_ALLOWED: "IMPERSONATION_NOT_ALLOWED";
21
+ /** A impersonação (30 minutos) acabou: entre de novo. */
22
+ readonly IMPERSONATION_EXPIRED: "IMPERSONATION_EXPIRED";
23
+ /** Sessão de impersonação tentando escrever: só leitura. */
24
+ readonly IMPERSONATION_READ_ONLY: "IMPERSONATION_READ_ONLY";
25
+ /** O Accounts não respondeu como esperado. */
26
+ readonly UPSTREAM_FAILED: "UPSTREAM_FAILED";
27
+ /** Chegou um webhook, mas `webhooks` não foi configurado no plugin. */
28
+ readonly WEBHOOKS_NOT_CONFIGURED: "WEBHOOKS_NOT_CONFIGURED";
29
+ /** Webhook sem assinatura válida (segredo errado, corpo alterado ou replay). */
30
+ readonly INVALID_WEBHOOK_SIGNATURE: "INVALID_WEBHOOK_SIGNATURE";
31
+ };
32
+ type RockfellerErrorCode = (typeof RockfellerErrorCode)[keyof typeof RockfellerErrorCode] | (string & {});
33
+ /** Erro do plugin ou do Accounts. Decida pelo `code`, nunca pela mensagem. */
34
+ declare class RockfellerError extends Error {
35
+ readonly code: RockfellerErrorCode;
36
+ readonly status: number;
37
+ readonly name: string;
38
+ constructor(code: RockfellerErrorCode, status: number, message?: string);
39
+ }
40
+ declare function isRockfellerError(error: unknown): error is RockfellerError;
41
+ /** Tema da pessoa na rede toda; `system` segue o aparelho e é o padrão de quem nunca escolheu. */
42
+ type Theme = 'light' | 'dark' | 'system';
43
+ /** Fuso do Brasil (IANA), um por horário. */
44
+ type Timezone = 'America/Noronha' | 'America/Sao_Paulo' | 'America/Manaus' | 'America/Rio_Branco';
45
+ type ReducedMotion = 'system' | 'reduce' | 'no-preference';
46
+ type Contrast = 'system' | 'more' | 'default';
47
+ type HourCycle = 'auto' | '12' | '24';
48
+ /** Preferências da pessoa na rede toda; quem nunca escolheu recebe o padrão de cada uma. */
49
+ interface Preferences {
50
+ theme: Theme;
51
+ /** `America/Sao_Paulo` por padrão. */
52
+ timezone: Timezone;
53
+ /** Como a pessoa quer ser chamada; `null` se não definiu (use o `name`). */
54
+ displayName: string | null;
55
+ reducedMotion: ReducedMotion;
56
+ contrast: Contrast;
57
+ hourCycle: HourCycle;
58
+ }
59
+ /** Só as chaves enviadas mudam; `displayName: null` apaga o nome de exibição. */
60
+ interface PreferencesPatch {
61
+ theme?: Theme | undefined;
62
+ timezone?: Timezone | undefined;
63
+ displayName?: string | null | undefined;
64
+ reducedMotion?: ReducedMotion | undefined;
65
+ contrast?: Contrast | undefined;
66
+ hourCycle?: HourCycle | undefined;
67
+ }
68
+ /** Tipo da organização no Accounts. A franqueadora também aparece como escola. */
69
+ type SchoolType = 'escola' | 'franqueadora';
70
+ /** Uma permissão concedida, no formato `app:recurso.acao`. */
71
+ interface Permission {
72
+ key: string;
73
+ /**
74
+ * Idade máxima do login, em segundos, para usar a permissão. `null` quando
75
+ * não é sensível. Compare com o `authTime` da conta.
76
+ */
77
+ maxAuthAgeSeconds: number | null;
78
+ }
79
+ interface School {
80
+ id: string;
81
+ name: string;
82
+ type: SchoolType;
83
+ /** Id da unidade no Joy, quando a escola veio de lá. */
84
+ joyUnitId: string | null;
85
+ }
86
+ /** Escola em que a pessoa atua, com os papéis e as permissões dela ali. */
87
+ interface SchoolMembership extends School {
88
+ roles: string[];
89
+ permissions: Permission[];
90
+ }
91
+ interface SchoolList {
92
+ schools: SchoolMembership[];
93
+ /** A pessoa tem `<app>:app.access` em alguma escola. */
94
+ appAccess: boolean;
95
+ accountActive: boolean;
96
+ }
97
+ /** O que a pessoa pode fazer numa escola. */
98
+ interface SchoolPermissions {
99
+ /** `null` quando a escola não existe ou está inativa. */
100
+ school: School | null;
101
+ accountActive: boolean;
102
+ /** Tem vínculo válido com a escola. */
103
+ member: boolean;
104
+ roles: string[];
105
+ permissions: Permission[];
106
+ }
107
+ /**
108
+ * Escola por id do Accounts ou pela unidade do Joy.
109
+ *
110
+ * @example
111
+ * 'org_123'
112
+ * { joyUnit: '987' }
113
+ */
114
+ type SchoolRef = string | {
115
+ joyUnit: string;
116
+ };
117
+ type TeamRoleOrigin = 'joy' | 'invite' | 'franchisor';
118
+ interface TeamRole {
119
+ key: string;
120
+ origin: TeamRoleOrigin;
121
+ grantedAt: string;
122
+ }
123
+ interface TeamMember {
124
+ userId: string;
125
+ name: string;
126
+ email: string;
127
+ status: 'active' | 'pending' | 'disabled';
128
+ roles: TeamRole[];
129
+ }
130
+ interface Page<T> {
131
+ items: T[];
132
+ /** Passe em `cursor` para a próxima página; `null` na última. */
133
+ nextCursor: string | null;
134
+ }
135
+ interface TeamMembersQuery {
136
+ /** Busca por nome ou e-mail. */
137
+ q?: string | undefined;
138
+ role?: string | undefined;
139
+ origin?: TeamRoleOrigin | undefined;
140
+ cursor?: string | undefined;
141
+ limit?: number | undefined;
142
+ }
143
+ /** Papéis que a gestão de equipe pode conceder. */
144
+ type TeamRoleKey = 'coordenador' | 'secretaria' | 'financeiro' | 'gestor_unidade' | 'franqueado' | 'afiliado';
145
+ interface TeamInvitationInput {
146
+ email: string;
147
+ name: string;
148
+ roles: TeamRoleKey[];
149
+ }
150
+ interface TeamInvitation {
151
+ userId: string;
152
+ /** A pessoa não tinha conta: recebeu um e-mail de ativação. */
153
+ accountCreated: boolean;
154
+ granted: string[];
155
+ }
156
+ export { RockfellerError as C, Timezone as S, RockfellerErrorCode as T, HourCycle as _, TeamMembersQuery as a, ReducedMotion as b, TeamRoleOrigin as c, SchoolList as d, SchoolMembership as f, Contrast as g, SchoolType as h, TeamMember as i, Permission as l, SchoolRef as m, TeamInvitation as n, TeamRole as o, SchoolPermissions as p, TeamInvitationInput as r, TeamRoleKey as s, Page as t, School as u, Preferences as v, isRockfellerError as w, Theme as x, PreferencesPatch as y };
157
+ //# sourceMappingURL=team-CJVAg4HH.d.cts.map
@@ -0,0 +1,157 @@
1
+ /** Códigos próprios do plugin; os do Accounts passam adiante como vieram. */
2
+ declare const RockfellerErrorCode: {
3
+ /** A pessoa não entrou pela Conta Rockfeller (sem conta `rockfeller`). */
4
+ readonly NOT_CONNECTED: "NOT_CONNECTED";
5
+ /** A gestão de equipe ainda não foi vinculada (`team.connect`). */
6
+ readonly TEAM_NOT_CONNECTED: "TEAM_NOT_CONNECTED";
7
+ /** `team: true` não foi ligado no plugin. */
8
+ readonly TEAM_NOT_ENABLED: "TEAM_NOT_ENABLED";
9
+ /** `api` não foi configurado no plugin. */
10
+ readonly API_NOT_CONFIGURED: "API_NOT_CONFIGURED";
11
+ /** Login por e-mail e senha desligado (`allowLocalSignIn`). */
12
+ readonly LOCAL_SIGN_IN_DISABLED: "LOCAL_SIGN_IN_DISABLED";
13
+ /** Sem a permissão pedida na escola. */
14
+ readonly FORBIDDEN: "FORBIDDEN";
15
+ /** Token ausente, inválido ou expirado. */
16
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
17
+ /** Token trocado (`act`) por um cliente que a API não aceita em nome da pessoa. */
18
+ readonly UNTRUSTED_ACTOR: "UNTRUSTED_ACTOR";
19
+ /** Token de impersonação (um admin vendo como a pessoa) numa API que não o aceita. */
20
+ readonly IMPERSONATION_NOT_ALLOWED: "IMPERSONATION_NOT_ALLOWED";
21
+ /** A impersonação (30 minutos) acabou: entre de novo. */
22
+ readonly IMPERSONATION_EXPIRED: "IMPERSONATION_EXPIRED";
23
+ /** Sessão de impersonação tentando escrever: só leitura. */
24
+ readonly IMPERSONATION_READ_ONLY: "IMPERSONATION_READ_ONLY";
25
+ /** O Accounts não respondeu como esperado. */
26
+ readonly UPSTREAM_FAILED: "UPSTREAM_FAILED";
27
+ /** Chegou um webhook, mas `webhooks` não foi configurado no plugin. */
28
+ readonly WEBHOOKS_NOT_CONFIGURED: "WEBHOOKS_NOT_CONFIGURED";
29
+ /** Webhook sem assinatura válida (segredo errado, corpo alterado ou replay). */
30
+ readonly INVALID_WEBHOOK_SIGNATURE: "INVALID_WEBHOOK_SIGNATURE";
31
+ };
32
+ type RockfellerErrorCode = (typeof RockfellerErrorCode)[keyof typeof RockfellerErrorCode] | (string & {});
33
+ /** Erro do plugin ou do Accounts. Decida pelo `code`, nunca pela mensagem. */
34
+ declare class RockfellerError extends Error {
35
+ readonly code: RockfellerErrorCode;
36
+ readonly status: number;
37
+ readonly name: string;
38
+ constructor(code: RockfellerErrorCode, status: number, message?: string);
39
+ }
40
+ declare function isRockfellerError(error: unknown): error is RockfellerError;
41
+ /** Tema da pessoa na rede toda; `system` segue o aparelho e é o padrão de quem nunca escolheu. */
42
+ type Theme = 'light' | 'dark' | 'system';
43
+ /** Fuso do Brasil (IANA), um por horário. */
44
+ type Timezone = 'America/Noronha' | 'America/Sao_Paulo' | 'America/Manaus' | 'America/Rio_Branco';
45
+ type ReducedMotion = 'system' | 'reduce' | 'no-preference';
46
+ type Contrast = 'system' | 'more' | 'default';
47
+ type HourCycle = 'auto' | '12' | '24';
48
+ /** Preferências da pessoa na rede toda; quem nunca escolheu recebe o padrão de cada uma. */
49
+ interface Preferences {
50
+ theme: Theme;
51
+ /** `America/Sao_Paulo` por padrão. */
52
+ timezone: Timezone;
53
+ /** Como a pessoa quer ser chamada; `null` se não definiu (use o `name`). */
54
+ displayName: string | null;
55
+ reducedMotion: ReducedMotion;
56
+ contrast: Contrast;
57
+ hourCycle: HourCycle;
58
+ }
59
+ /** Só as chaves enviadas mudam; `displayName: null` apaga o nome de exibição. */
60
+ interface PreferencesPatch {
61
+ theme?: Theme | undefined;
62
+ timezone?: Timezone | undefined;
63
+ displayName?: string | null | undefined;
64
+ reducedMotion?: ReducedMotion | undefined;
65
+ contrast?: Contrast | undefined;
66
+ hourCycle?: HourCycle | undefined;
67
+ }
68
+ /** Tipo da organização no Accounts. A franqueadora também aparece como escola. */
69
+ type SchoolType = 'escola' | 'franqueadora';
70
+ /** Uma permissão concedida, no formato `app:recurso.acao`. */
71
+ interface Permission {
72
+ key: string;
73
+ /**
74
+ * Idade máxima do login, em segundos, para usar a permissão. `null` quando
75
+ * não é sensível. Compare com o `authTime` da conta.
76
+ */
77
+ maxAuthAgeSeconds: number | null;
78
+ }
79
+ interface School {
80
+ id: string;
81
+ name: string;
82
+ type: SchoolType;
83
+ /** Id da unidade no Joy, quando a escola veio de lá. */
84
+ joyUnitId: string | null;
85
+ }
86
+ /** Escola em que a pessoa atua, com os papéis e as permissões dela ali. */
87
+ interface SchoolMembership extends School {
88
+ roles: string[];
89
+ permissions: Permission[];
90
+ }
91
+ interface SchoolList {
92
+ schools: SchoolMembership[];
93
+ /** A pessoa tem `<app>:app.access` em alguma escola. */
94
+ appAccess: boolean;
95
+ accountActive: boolean;
96
+ }
97
+ /** O que a pessoa pode fazer numa escola. */
98
+ interface SchoolPermissions {
99
+ /** `null` quando a escola não existe ou está inativa. */
100
+ school: School | null;
101
+ accountActive: boolean;
102
+ /** Tem vínculo válido com a escola. */
103
+ member: boolean;
104
+ roles: string[];
105
+ permissions: Permission[];
106
+ }
107
+ /**
108
+ * Escola por id do Accounts ou pela unidade do Joy.
109
+ *
110
+ * @example
111
+ * 'org_123'
112
+ * { joyUnit: '987' }
113
+ */
114
+ type SchoolRef = string | {
115
+ joyUnit: string;
116
+ };
117
+ type TeamRoleOrigin = 'joy' | 'invite' | 'franchisor';
118
+ interface TeamRole {
119
+ key: string;
120
+ origin: TeamRoleOrigin;
121
+ grantedAt: string;
122
+ }
123
+ interface TeamMember {
124
+ userId: string;
125
+ name: string;
126
+ email: string;
127
+ status: 'active' | 'pending' | 'disabled';
128
+ roles: TeamRole[];
129
+ }
130
+ interface Page<T> {
131
+ items: T[];
132
+ /** Passe em `cursor` para a próxima página; `null` na última. */
133
+ nextCursor: string | null;
134
+ }
135
+ interface TeamMembersQuery {
136
+ /** Busca por nome ou e-mail. */
137
+ q?: string | undefined;
138
+ role?: string | undefined;
139
+ origin?: TeamRoleOrigin | undefined;
140
+ cursor?: string | undefined;
141
+ limit?: number | undefined;
142
+ }
143
+ /** Papéis que a gestão de equipe pode conceder. */
144
+ type TeamRoleKey = 'coordenador' | 'secretaria' | 'financeiro' | 'gestor_unidade' | 'franqueado' | 'afiliado';
145
+ interface TeamInvitationInput {
146
+ email: string;
147
+ name: string;
148
+ roles: TeamRoleKey[];
149
+ }
150
+ interface TeamInvitation {
151
+ userId: string;
152
+ /** A pessoa não tinha conta: recebeu um e-mail de ativação. */
153
+ accountCreated: boolean;
154
+ granted: string[];
155
+ }
156
+ export { RockfellerError as C, Timezone as S, RockfellerErrorCode as T, HourCycle as _, TeamMembersQuery as a, ReducedMotion as b, TeamRoleOrigin as c, SchoolList as d, SchoolMembership as f, Contrast as g, SchoolType as h, TeamMember as i, Permission as l, SchoolRef as m, TeamInvitation as n, TeamRole as o, SchoolPermissions as p, TeamInvitationInput as r, TeamRoleKey as s, Page as t, School as u, Preferences as v, isRockfellerError as w, Theme as x, PreferencesPatch as y };
157
+ //# sourceMappingURL=team-CJVAg4HH.d.ts.map
@@ -0,0 +1,6 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_define_adapter = require("../define-adapter-Cc0QrfKt.cjs");
3
+ const require_dispatcher = require("../dispatcher-BsD7cO2w.cjs");
4
+
5
+ exports.TelemetryAdapterDispatcher = require_dispatcher.TelemetryAdapterDispatcher;
6
+ exports.defineAdapter = require_define_adapter.defineAdapter;
@@ -0,0 +1,3 @@
1
+ import { a as TelemetryExceptionRecord, c as TelemetryMetricRecord, d as TelemetrySpanRecord, i as TelemetryEventRecord, l as TelemetryOtlpConfiguration, n as TelemetryAdapterCapabilities, o as TelemetryLogLevel, r as TelemetryAdapterDefinition, s as TelemetryLogRecord, t as TelemetryAdapter, u as TelemetrySpanEventRecord } from "../adapters-DM59AJfR.cjs";
2
+ import { n as defineAdapter, t as TelemetryAdapterDispatcher } from "../index-DDSaLjXV.cjs";
3
+ export { type TelemetryAdapter, type TelemetryAdapterCapabilities, type TelemetryAdapterDefinition, TelemetryAdapterDispatcher, type TelemetryEventRecord, type TelemetryExceptionRecord, type TelemetryLogLevel, type TelemetryLogRecord, type TelemetryMetricRecord, type TelemetryOtlpConfiguration, type TelemetrySpanEventRecord, type TelemetrySpanRecord, defineAdapter };
@@ -0,0 +1,3 @@
1
+ import { a as TelemetryExceptionRecord, c as TelemetryMetricRecord, d as TelemetrySpanRecord, i as TelemetryEventRecord, l as TelemetryOtlpConfiguration, n as TelemetryAdapterCapabilities, o as TelemetryLogLevel, r as TelemetryAdapterDefinition, s as TelemetryLogRecord, t as TelemetryAdapter, u as TelemetrySpanEventRecord } from "../adapters-DM59AJfR.js";
2
+ import { n as defineAdapter, t as TelemetryAdapterDispatcher } from "../index-By8b4ksT.js";
3
+ export { type TelemetryAdapter, type TelemetryAdapterCapabilities, type TelemetryAdapterDefinition, TelemetryAdapterDispatcher, type TelemetryEventRecord, type TelemetryExceptionRecord, type TelemetryLogLevel, type TelemetryLogRecord, type TelemetryMetricRecord, type TelemetryOtlpConfiguration, type TelemetrySpanEventRecord, type TelemetrySpanRecord, defineAdapter };
@@ -0,0 +1,4 @@
1
+ import { t as defineAdapter } from "../define-adapter-DRcXno3j.js";
2
+ import { t as TelemetryAdapterDispatcher } from "../dispatcher-DA_l1Vkv.js";
3
+
4
+ export { TelemetryAdapterDispatcher, defineAdapter };