@vibes.diy/api-types 4.5.5 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/access-function.d.ts +4 -0
  2. package/app-documents.d.ts +7 -0
  3. package/app-documents.js +8 -0
  4. package/app-documents.js.map +1 -1
  5. package/app.d.ts +248 -194
  6. package/app.js +37 -0
  7. package/app.js.map +1 -1
  8. package/audience-arms-msg.d.ts +94 -0
  9. package/audience-arms-msg.js +90 -0
  10. package/audience-arms-msg.js.map +1 -0
  11. package/billing-msg.d.ts +78 -0
  12. package/billing-msg.js +67 -0
  13. package/billing-msg.js.map +1 -0
  14. package/cf-env.d.ts +4 -0
  15. package/db-acls.d.ts +0 -2
  16. package/db-acls.js +0 -2
  17. package/db-acls.js.map +1 -1
  18. package/developer-grant.d.ts +96 -0
  19. package/developer-grant.js +87 -0
  20. package/developer-grant.js.map +1 -0
  21. package/email-unsubscribe.d.ts +3 -0
  22. package/email-unsubscribe.js +33 -0
  23. package/email-unsubscribe.js.map +1 -0
  24. package/home-feed.d.ts +79 -0
  25. package/home-feed.js +52 -0
  26. package/home-feed.js.map +1 -0
  27. package/index.d.ts +7 -0
  28. package/index.js +7 -0
  29. package/index.js.map +1 -1
  30. package/invite.d.ts +54 -15
  31. package/invite.js +28 -1
  32. package/invite.js.map +1 -1
  33. package/notifications.d.ts +39 -2
  34. package/notifications.js +39 -2
  35. package/notifications.js.map +1 -1
  36. package/package.json +7 -6
  37. package/related-vibes.d.ts +72 -0
  38. package/related-vibes.js +53 -0
  39. package/related-vibes.js.map +1 -0
  40. package/settings.d.ts +173 -7
  41. package/settings.js +46 -1
  42. package/settings.js.map +1 -1
  43. package/shard-policy.d.ts +28 -0
  44. package/shard-policy.js +28 -0
  45. package/shard-policy.js.map +1 -1
  46. package/social-msg.d.ts +294 -0
  47. package/social-msg.js +249 -0
  48. package/social-msg.js.map +1 -0
  49. package/types.d.ts +6 -0
  50. package/types.js +3 -0
  51. package/types.js.map +1 -1
  52. package/vibes-diy-api.d.ts +35 -1
  53. package/vibes-diy-api.js.map +1 -1
  54. package/vibes-diy-serv-ctx.js.map +1 -1
@@ -0,0 +1,94 @@
1
+ export declare const AudienceArmState: import("arktype/internal/variants/string.ts").StringType<"allow" | "deny", {}>;
2
+ export type AudienceArmState = typeof AudienceArmState.infer;
3
+ export declare const AudiencePolicy: import("arktype/internal/variants/string.ts").StringType<"always-allow" | "ask" | "never-allow", {}>;
4
+ export type AudiencePolicy = typeof AudiencePolicy.infer;
5
+ export declare const ReqAudienceArmState: import("arktype/internal/variants/object.ts").ObjectType<{
6
+ type: "vibes.diy.req-audience-arm-state";
7
+ auth: {
8
+ type: "clerk" | "device-id" | "ucan";
9
+ token: string;
10
+ };
11
+ ownerHandle: string;
12
+ appSlug: string;
13
+ }, {}>;
14
+ export type ReqAudienceArmState = typeof ReqAudienceArmState.infer;
15
+ export declare function isReqAudienceArmState(obj: unknown): obj is ReqAudienceArmState;
16
+ export declare const ResAudienceArmState: import("arktype/internal/variants/object.ts").ObjectType<{
17
+ type: "vibes.diy.res-audience-arm-state";
18
+ ownerHandle: string;
19
+ appSlug: string;
20
+ state: "allow" | "deny" | null;
21
+ policy: "always-allow" | "ask" | "never-allow";
22
+ sensitive: boolean;
23
+ }, {}>;
24
+ export type ResAudienceArmState = typeof ResAudienceArmState.infer;
25
+ export declare function isResAudienceArmState(obj: unknown): obj is ResAudienceArmState;
26
+ export declare const ReqSetAudienceArm: import("arktype/internal/variants/object.ts").ObjectType<{
27
+ type: "vibes.diy.req-set-audience-arm";
28
+ auth: {
29
+ type: "clerk" | "device-id" | "ucan";
30
+ token: string;
31
+ };
32
+ ownerHandle: string;
33
+ appSlug: string;
34
+ state: "allow" | "deny" | null;
35
+ }, {}>;
36
+ export type ReqSetAudienceArm = typeof ReqSetAudienceArm.infer;
37
+ export declare function isReqSetAudienceArm(obj: unknown): obj is ReqSetAudienceArm;
38
+ export declare const ResSetAudienceArm: import("arktype/internal/variants/object.ts").ObjectType<{
39
+ type: "vibes.diy.res-set-audience-arm";
40
+ ownerHandle: string;
41
+ appSlug: string;
42
+ state: "allow" | "deny" | null;
43
+ }, {}>;
44
+ export type ResSetAudienceArm = typeof ResSetAudienceArm.infer;
45
+ export declare function isResSetAudienceArm(obj: unknown): obj is ResSetAudienceArm;
46
+ export declare const ReqSetAudiencePolicy: import("arktype/internal/variants/object.ts").ObjectType<{
47
+ type: "vibes.diy.req-set-audience-policy";
48
+ auth: {
49
+ type: "clerk" | "device-id" | "ucan";
50
+ token: string;
51
+ };
52
+ policy: "always-allow" | "ask" | "never-allow";
53
+ }, {}>;
54
+ export type ReqSetAudiencePolicy = typeof ReqSetAudiencePolicy.infer;
55
+ export declare function isReqSetAudiencePolicy(obj: unknown): obj is ReqSetAudiencePolicy;
56
+ export declare const ResSetAudiencePolicy: import("arktype/internal/variants/object.ts").ObjectType<{
57
+ type: "vibes.diy.res-set-audience-policy";
58
+ policy: "always-allow" | "ask" | "never-allow";
59
+ }, {}>;
60
+ export type ResSetAudiencePolicy = typeof ResSetAudiencePolicy.infer;
61
+ export declare function isResSetAudiencePolicy(obj: unknown): obj is ResSetAudiencePolicy;
62
+ export declare const AudienceArmEntry: import("arktype/internal/variants/object.ts").ObjectType<{
63
+ ownerHandle: string;
64
+ appSlug: string;
65
+ state: "allow" | "deny";
66
+ }, {}>;
67
+ export type AudienceArmEntry = typeof AudienceArmEntry.infer;
68
+ export declare const ReqListAudienceArms: import("arktype/internal/variants/object.ts").ObjectType<{
69
+ type: "vibes.diy.req-list-audience-arms";
70
+ auth: {
71
+ type: "clerk" | "device-id" | "ucan";
72
+ token: string;
73
+ };
74
+ }, {}>;
75
+ export type ReqListAudienceArms = typeof ReqListAudienceArms.infer;
76
+ export declare function isReqListAudienceArms(obj: unknown): obj is ReqListAudienceArms;
77
+ export declare const ResListAudienceArms: import("arktype/internal/variants/object.ts").ObjectType<{
78
+ type: "vibes.diy.res-list-audience-arms";
79
+ policy: "always-allow" | "ask" | "never-allow";
80
+ arms: {
81
+ ownerHandle: string;
82
+ appSlug: string;
83
+ state: "allow" | "deny";
84
+ }[];
85
+ }, {}>;
86
+ export type ResListAudienceArms = typeof ResListAudienceArms.infer;
87
+ export declare function isResListAudienceArms(obj: unknown): obj is ResListAudienceArms;
88
+ export type PromptOutcome = "prompt" | "auto-allow" | "silent-deny";
89
+ export interface ResolvePromptOutcomeArgs {
90
+ readonly policy: AudiencePolicy;
91
+ readonly sensitive: boolean;
92
+ readonly prior: AudienceArmState | null;
93
+ }
94
+ export declare function resolvePromptOutcome({ policy, sensitive, prior }: ResolvePromptOutcomeArgs): PromptOutcome;
@@ -0,0 +1,90 @@
1
+ import { type } from "arktype";
2
+ import { dashAuthType } from "./common.js";
3
+ export const AudienceArmState = type("'allow' | 'deny'");
4
+ export const AudiencePolicy = type("'ask' | 'always-allow' | 'never-allow'");
5
+ export const ReqAudienceArmState = type({
6
+ type: "'vibes.diy.req-audience-arm-state'",
7
+ auth: dashAuthType,
8
+ ownerHandle: "string",
9
+ appSlug: "string",
10
+ });
11
+ export function isReqAudienceArmState(obj) {
12
+ return !(ReqAudienceArmState(obj) instanceof type.errors);
13
+ }
14
+ export const ResAudienceArmState = type({
15
+ type: "'vibes.diy.res-audience-arm-state'",
16
+ ownerHandle: "string",
17
+ appSlug: "string",
18
+ state: AudienceArmState.or("null"),
19
+ policy: AudiencePolicy,
20
+ sensitive: "boolean",
21
+ });
22
+ export function isResAudienceArmState(obj) {
23
+ return !(ResAudienceArmState(obj) instanceof type.errors);
24
+ }
25
+ export const ReqSetAudienceArm = type({
26
+ type: "'vibes.diy.req-set-audience-arm'",
27
+ auth: dashAuthType,
28
+ ownerHandle: "string",
29
+ appSlug: "string",
30
+ state: AudienceArmState.or("null"),
31
+ });
32
+ export function isReqSetAudienceArm(obj) {
33
+ return !(ReqSetAudienceArm(obj) instanceof type.errors);
34
+ }
35
+ export const ResSetAudienceArm = type({
36
+ type: "'vibes.diy.res-set-audience-arm'",
37
+ ownerHandle: "string",
38
+ appSlug: "string",
39
+ state: AudienceArmState.or("null"),
40
+ });
41
+ export function isResSetAudienceArm(obj) {
42
+ return !(ResSetAudienceArm(obj) instanceof type.errors);
43
+ }
44
+ export const ReqSetAudiencePolicy = type({
45
+ type: "'vibes.diy.req-set-audience-policy'",
46
+ auth: dashAuthType,
47
+ policy: AudiencePolicy,
48
+ });
49
+ export function isReqSetAudiencePolicy(obj) {
50
+ return !(ReqSetAudiencePolicy(obj) instanceof type.errors);
51
+ }
52
+ export const ResSetAudiencePolicy = type({
53
+ type: "'vibes.diy.res-set-audience-policy'",
54
+ policy: AudiencePolicy,
55
+ });
56
+ export function isResSetAudiencePolicy(obj) {
57
+ return !(ResSetAudiencePolicy(obj) instanceof type.errors);
58
+ }
59
+ export const AudienceArmEntry = type({
60
+ ownerHandle: "string",
61
+ appSlug: "string",
62
+ state: AudienceArmState,
63
+ });
64
+ export const ReqListAudienceArms = type({
65
+ type: "'vibes.diy.req-list-audience-arms'",
66
+ auth: dashAuthType,
67
+ });
68
+ export function isReqListAudienceArms(obj) {
69
+ return !(ReqListAudienceArms(obj) instanceof type.errors);
70
+ }
71
+ export const ResListAudienceArms = type({
72
+ type: "'vibes.diy.res-list-audience-arms'",
73
+ policy: AudiencePolicy,
74
+ arms: AudienceArmEntry.array(),
75
+ });
76
+ export function isResListAudienceArms(obj) {
77
+ return !(ResListAudienceArms(obj) instanceof type.errors);
78
+ }
79
+ export function resolvePromptOutcome({ policy, sensitive, prior }) {
80
+ if (prior === "allow")
81
+ return "auto-allow";
82
+ if (prior === "deny")
83
+ return "silent-deny";
84
+ if (policy === "never-allow")
85
+ return "silent-deny";
86
+ if (policy === "always-allow" && sensitive === false)
87
+ return "auto-allow";
88
+ return "prompt";
89
+ }
90
+ //# sourceMappingURL=audience-arms-msg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audience-arms-msg.js","sourceRoot":"","sources":["../jsr/audience-arms-msg.ts"],"names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AAEH,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,OAAO,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;IACtC,IAAI,EAAE,oCAAoC;IAC1C,MAAM,EAAE,cAAc;IACtB,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,OAAO,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AA6CD,MAAM,UAAU,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAA4B;IACzF,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,YAAY,CAAC;IAC3C,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,aAAa,CAAC;IAC3C,IAAI,MAAM,KAAK,aAAa;QAAE,OAAO,aAAa,CAAC;IACnD,IAAI,MAAM,KAAK,cAAc,IAAI,SAAS,KAAK,KAAK;QAAE,OAAO,YAAY,CAAC;IAC1E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,78 @@
1
+ export declare const billingAutoRefill: import("arktype/internal/variants/object.ts").ObjectType<{
2
+ enabled: boolean;
3
+ threshold: number;
4
+ reloadUsd: number;
5
+ capUsd: number;
6
+ }, {}>;
7
+ export type BillingAutoRefill = typeof billingAutoRefill.infer;
8
+ export declare const reqBillingCustomer: import("arktype/internal/variants/object.ts").ObjectType<{
9
+ type: "vibes.diy.req-billing-customer";
10
+ auth: {
11
+ type: "clerk" | "device-id" | "ucan";
12
+ token: string;
13
+ };
14
+ }, {}>;
15
+ export type ReqBillingCustomer = typeof reqBillingCustomer.infer;
16
+ export declare function isReqBillingCustomer(obj: unknown): obj is ReqBillingCustomer;
17
+ export declare const resBillingCustomer: import("arktype/internal/variants/object.ts").ObjectType<{
18
+ type: "vibes.diy.res-billing-customer";
19
+ enabled: boolean;
20
+ plan?: "free" | "plus" | undefined;
21
+ grantRemaining?: number | undefined;
22
+ grantIncluded?: number | undefined;
23
+ grantResetsAt?: number | undefined;
24
+ purchasedRemaining?: number | undefined;
25
+ remaining?: number | undefined;
26
+ autoRefill?: {
27
+ enabled: boolean;
28
+ threshold: number;
29
+ reloadUsd: number;
30
+ capUsd: number;
31
+ } | undefined;
32
+ }, {}>;
33
+ export type ResBillingCustomer = typeof resBillingCustomer.infer;
34
+ export declare function isResBillingCustomer(obj: unknown): obj is ResBillingCustomer;
35
+ export declare const reqBillingCheckout: import("arktype/internal/variants/object.ts").ObjectType<{
36
+ type: "vibes.diy.req-billing-checkout";
37
+ auth: {
38
+ type: "clerk" | "device-id" | "ucan";
39
+ token: string;
40
+ };
41
+ kind: "subscribe-plus" | "top-up";
42
+ units?: number | undefined;
43
+ successUrl: string;
44
+ }, {}>;
45
+ export type ReqBillingCheckout = typeof reqBillingCheckout.infer;
46
+ export declare function isReqBillingCheckout(obj: unknown): obj is ReqBillingCheckout;
47
+ export declare const resBillingCheckout: import("arktype/internal/variants/object.ts").ObjectType<{
48
+ type: "vibes.diy.res-billing-checkout";
49
+ checkoutUrl: string;
50
+ }, {}>;
51
+ export type ResBillingCheckout = typeof resBillingCheckout.infer;
52
+ export declare function isResBillingCheckout(obj: unknown): obj is ResBillingCheckout;
53
+ export declare const reqBillingConfig: import("arktype/internal/variants/object.ts").ObjectType<{
54
+ type: "vibes.diy.req-billing-config";
55
+ auth: {
56
+ type: "clerk" | "device-id" | "ucan";
57
+ token: string;
58
+ };
59
+ autoRefill: {
60
+ enabled: boolean;
61
+ threshold: 100 | 200 | 500;
62
+ reloadUsd: 5 | 10 | 25;
63
+ capUsd: number;
64
+ };
65
+ }, {}>;
66
+ export type ReqBillingConfig = typeof reqBillingConfig.infer;
67
+ export declare function isReqBillingConfig(obj: unknown): obj is ReqBillingConfig;
68
+ export declare const resBillingConfig: import("arktype/internal/variants/object.ts").ObjectType<{
69
+ type: "vibes.diy.res-billing-config";
70
+ autoRefill: {
71
+ enabled: boolean;
72
+ threshold: number;
73
+ reloadUsd: number;
74
+ capUsd: number;
75
+ };
76
+ }, {}>;
77
+ export type ResBillingConfig = typeof resBillingConfig.infer;
78
+ export declare function isResBillingConfig(obj: unknown): obj is ResBillingConfig;
package/billing-msg.js ADDED
@@ -0,0 +1,67 @@
1
+ import { type } from "arktype";
2
+ import { dashAuthType } from "./common.js";
3
+ export const billingAutoRefill = type({
4
+ enabled: "boolean",
5
+ threshold: "number",
6
+ reloadUsd: "number",
7
+ capUsd: "number",
8
+ });
9
+ export const reqBillingCustomer = type({
10
+ type: "'vibes.diy.req-billing-customer'",
11
+ auth: dashAuthType,
12
+ });
13
+ export function isReqBillingCustomer(obj) {
14
+ return !(reqBillingCustomer(obj) instanceof type.errors);
15
+ }
16
+ export const resBillingCustomer = type({
17
+ type: "'vibes.diy.res-billing-customer'",
18
+ enabled: "boolean",
19
+ "plan?": "'free' | 'plus'",
20
+ "grantRemaining?": "number",
21
+ "grantIncluded?": "number",
22
+ "grantResetsAt?": "number",
23
+ "purchasedRemaining?": "number",
24
+ "remaining?": "number",
25
+ "autoRefill?": billingAutoRefill,
26
+ });
27
+ export function isResBillingCustomer(obj) {
28
+ return !(resBillingCustomer(obj) instanceof type.errors);
29
+ }
30
+ export const reqBillingCheckout = type({
31
+ type: "'vibes.diy.req-billing-checkout'",
32
+ auth: dashAuthType,
33
+ kind: "'subscribe-plus' | 'top-up'",
34
+ "units?": "number",
35
+ successUrl: "string",
36
+ });
37
+ export function isReqBillingCheckout(obj) {
38
+ return !(reqBillingCheckout(obj) instanceof type.errors);
39
+ }
40
+ export const resBillingCheckout = type({
41
+ type: "'vibes.diy.res-billing-checkout'",
42
+ checkoutUrl: "string",
43
+ });
44
+ export function isResBillingCheckout(obj) {
45
+ return !(resBillingCheckout(obj) instanceof type.errors);
46
+ }
47
+ export const reqBillingConfig = type({
48
+ type: "'vibes.diy.req-billing-config'",
49
+ auth: dashAuthType,
50
+ autoRefill: type({
51
+ enabled: "boolean",
52
+ threshold: "100 | 200 | 500",
53
+ reloadUsd: "5 | 10 | 25",
54
+ capUsd: "number",
55
+ }),
56
+ });
57
+ export function isReqBillingConfig(obj) {
58
+ return !(reqBillingConfig(obj) instanceof type.errors);
59
+ }
60
+ export const resBillingConfig = type({
61
+ type: "'vibes.diy.res-billing-config'",
62
+ autoRefill: billingAutoRefill,
63
+ });
64
+ export function isResBillingConfig(obj) {
65
+ return !(resBillingConfig(obj) instanceof type.errors);
66
+ }
67
+ //# sourceMappingURL=billing-msg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-msg.js","sourceRoot":"","sources":["../jsr/billing-msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,SAAS;IAElB,SAAS,EAAE,QAAQ;IAKnB,SAAS,EAAE,QAAQ;IACnB,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;IACrC,IAAI,EAAE,kCAAkC;IACxC,IAAI,EAAE,YAAY;CACnB,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;IACrC,IAAI,EAAE,kCAAkC;IACxC,OAAO,EAAE,SAAS;IAElB,OAAO,EAAE,iBAAiB;IAI1B,iBAAiB,EAAE,QAAQ;IAC3B,gBAAgB,EAA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AAI,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;IACnC,IAAI,EAAE,gCAAgC;IAEtC,UAAU,EAAE,iBAAiB;CAC9B,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC"}
package/cf-env.d.ts CHANGED
@@ -17,6 +17,9 @@ export interface CFEnv {
17
17
  RESEND_API_KEY: string;
18
18
  VIBES_DIY_FROM_EMAIL: string;
19
19
  DISCORD_WEBHOOK_URL?: string;
20
+ DISCORD_CURATION_BOT_TOKEN?: string;
21
+ DISCORD_CURATION_CHANNEL_ID?: string;
22
+ DISCORD_CURATION_PUBLIC_KEY?: string;
20
23
  LLM_BACKEND_URL: string;
21
24
  LLM_BACKEND_API_KEY: string;
22
25
  PRODIA_TOKEN?: string;
@@ -32,6 +35,7 @@ export interface CFEnv {
32
35
  LOADER?: unknown;
33
36
  BACKEND_POLICY_VERSION?: string;
34
37
  BACKEND_INTERNAL_SECRET?: string;
38
+ EMAIL_UNSUBSCRIBE_SECRET?: string;
35
39
  VIBES_ROOT_SWR?: string;
36
40
  VIBES_SERVICE: Queue;
37
41
  BROWSER: Fetcher;
package/db-acls.d.ts CHANGED
@@ -4,7 +4,6 @@ export declare const dbAclSubject: import("arktype/internal/variants/string.ts")
4
4
  export declare const dbAcl: import("arktype/internal/variants/object.ts").ObjectType<{
5
5
  read?: ("editors" | "members" | "readers" | "submitters")[] | undefined;
6
6
  write?: ("editors" | "members" | "readers" | "submitters")[] | undefined;
7
- delete?: ("editors" | "members" | "readers" | "submitters")[] | undefined;
8
7
  }, {}>;
9
8
  export declare function isDbAcl(obj: unknown): obj is DbAcl;
10
9
  export declare const COMMENTS_DB_NAME = "comments";
@@ -15,7 +14,6 @@ export declare const ActiveDbAcl: import("arktype/internal/variants/object.ts").
15
14
  acl: {
16
15
  read?: ("editors" | "members" | "readers" | "submitters")[] | undefined;
17
16
  write?: ("editors" | "members" | "readers" | "submitters")[] | undefined;
18
- delete?: ("editors" | "members" | "readers" | "submitters")[] | undefined;
19
17
  };
20
18
  }, {}>;
21
19
  export type ActiveDbAcl = typeof ActiveDbAcl.infer;
package/db-acls.js CHANGED
@@ -3,7 +3,6 @@ export const dbAclSubject = type("'members' | 'editors' | 'submitters' | 'reader
3
3
  export const dbAcl = type({
4
4
  "read?": dbAclSubject.array(),
5
5
  "write?": dbAclSubject.array(),
6
- "delete?": dbAclSubject.array(),
7
6
  });
8
7
  export function isDbAcl(obj) {
9
8
  return !(dbAcl(obj) instanceof type.errors);
@@ -11,7 +10,6 @@ export function isDbAcl(obj) {
11
10
  export const COMMENTS_DB_NAME = "comments";
12
11
  export const COMMENTS_DEFAULT_ACL = {
13
12
  write: ["members"],
14
- delete: ["members"],
15
13
  };
16
14
  export const ActiveDbAcl = type({
17
15
  type: "'active.db-acl'",
package/db-acls.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"db-acls.js","sourceRoot":"","sources":["../jsr/db-acls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AA2B/B,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,kDAAkD,CAAC,CAAC;AAErF,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE;IAC7B,QAAQ,EAAE,YAAY,CAAC,KAAK,EAAE;IAC9B,SAAS,EAAE,YAAY,CAAC,KAAK,EAAE;CAChC,CAAC,CAAC;AACH,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,U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W,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,96 @@
1
+ export declare const DeveloperGrantState: import("arktype/internal/variants/string.ts").StringType<"active" | "revoked", {}>;
2
+ export type DeveloperGrantState = typeof DeveloperGrantState.infer;
3
+ export declare const ReqEnsureDeveloperGrant: import("arktype/internal/variants/object.ts").ObjectType<{
4
+ type: "vibes.diy.req-ensure-developer-grant";
5
+ auth: {
6
+ type: "clerk" | "device-id" | "ucan";
7
+ token: string;
8
+ };
9
+ appSlug: string;
10
+ ownerHandle: string;
11
+ devHandle: string;
12
+ }, {}>;
13
+ export type ReqEnsureDeveloperGrant = typeof ReqEnsureDeveloperGrant.infer;
14
+ export declare function isReqEnsureDeveloperGrant(obj: unknown): obj is ReqEnsureDeveloperGrant;
15
+ export declare const ResEnsureDeveloperGrant: import("arktype/internal/variants/object.ts").ObjectType<{
16
+ type: "vibes.diy.res-ensure-developer-grant";
17
+ appSlug: string;
18
+ ownerHandle: string;
19
+ devHandle: string;
20
+ devUserId: string;
21
+ state: "active" | "revoked";
22
+ updated: string;
23
+ created: string;
24
+ }, {}>;
25
+ export type ResEnsureDeveloperGrant = typeof ResEnsureDeveloperGrant.infer;
26
+ export declare function isResEnsureDeveloperGrant(obj: unknown): obj is ResEnsureDeveloperGrant;
27
+ export declare const ReqRevokeDeveloperGrant: import("arktype/internal/variants/object.ts").ObjectType<{
28
+ type: "vibes.diy.req-revoke-developer-grant";
29
+ auth: {
30
+ type: "clerk" | "device-id" | "ucan";
31
+ token: string;
32
+ };
33
+ appSlug: string;
34
+ ownerHandle: string;
35
+ devHandle: string;
36
+ }, {}>;
37
+ export type ReqRevokeDeveloperGrant = typeof ReqRevokeDeveloperGrant.infer;
38
+ export declare function isReqRevokeDeveloperGrant(obj: unknown): obj is ReqRevokeDeveloperGrant;
39
+ export declare const ResRevokeDeveloperGrant: import("arktype/internal/variants/object.ts").ObjectType<{
40
+ type: "vibes.diy.res-revoke-developer-grant";
41
+ appSlug: string;
42
+ ownerHandle: string;
43
+ devHandle: string;
44
+ state: "revoked";
45
+ updated: string;
46
+ }, {}>;
47
+ export type ResRevokeDeveloperGrant = typeof ResRevokeDeveloperGrant.infer;
48
+ export declare function isResRevokeDeveloperGrant(obj: unknown): obj is ResRevokeDeveloperGrant;
49
+ export declare const ReqListDeveloperGrants: import("arktype/internal/variants/object.ts").ObjectType<{
50
+ appSlug: string;
51
+ ownerHandle: string;
52
+ auth: {
53
+ type: "clerk" | "device-id" | "ucan";
54
+ token: string;
55
+ };
56
+ pager: {
57
+ limit?: number | undefined;
58
+ cursor?: string | undefined;
59
+ };
60
+ type: "vibes.diy.req-list-developer-grants";
61
+ }, {}>;
62
+ export type ReqListDeveloperGrants = typeof ReqListDeveloperGrants.infer;
63
+ export declare function isReqListDeveloperGrants(obj: unknown): obj is ReqListDeveloperGrants;
64
+ export declare const ResListDeveloperGrants: import("arktype/internal/variants/object.ts").ObjectType<{
65
+ type: "vibes.diy.res-list-developer-grants";
66
+ appSlug: string;
67
+ ownerHandle: string;
68
+ items: {
69
+ devHandle: string;
70
+ devUserId: string;
71
+ state: "active" | "revoked";
72
+ updated: string;
73
+ created: string;
74
+ }[];
75
+ nextCursor?: string | undefined;
76
+ }, {}>;
77
+ export type ResListDeveloperGrants = typeof ResListDeveloperGrants.infer;
78
+ export declare function isResListDeveloperGrants(obj: unknown): obj is ResListDeveloperGrants;
79
+ export declare const ResDeveloperGrantOwnerError: import("arktype/internal/variants/object.ts").ObjectType<{
80
+ type: "vibes.diy.res-error";
81
+ error: {
82
+ message: string;
83
+ code: "developer-grant-owner-error";
84
+ };
85
+ }, {}>;
86
+ export type ResDeveloperGrantOwnerError = typeof ResDeveloperGrantOwnerError.infer;
87
+ export declare function isResDeveloperGrantOwnerError(obj: unknown): obj is ResDeveloperGrantOwnerError;
88
+ export declare const ResDeveloperGrantError: import("arktype/internal/variants/object.ts").ObjectType<{
89
+ type: "vibes.diy.res-error";
90
+ error: {
91
+ message: string;
92
+ code: "developer-grant-app-not-found" | "developer-grant-not-found" | "developer-grant-self-handle" | "developer-grant-unbound-handle";
93
+ };
94
+ }, {}>;
95
+ export type ResDeveloperGrantError = typeof ResDeveloperGrantError.infer;
96
+ export declare function isResDeveloperGrantError(obj: unknown): obj is ResDeveloperGrantError;
@@ -0,0 +1,87 @@
1
+ import { type } from "arktype";
2
+ import { dashAuthType, GrantListBase } from "./common.js";
3
+ export const DeveloperGrantState = type("'active' | 'revoked'");
4
+ export const ReqEnsureDeveloperGrant = type({
5
+ type: "'vibes.diy.req-ensure-developer-grant'",
6
+ auth: dashAuthType,
7
+ appSlug: "string",
8
+ ownerHandle: "string",
9
+ devHandle: "string",
10
+ });
11
+ export function isReqEnsureDeveloperGrant(obj) {
12
+ return !(ReqEnsureDeveloperGrant(obj) instanceof type.errors);
13
+ }
14
+ export const ResEnsureDeveloperGrant = type({
15
+ type: "'vibes.diy.res-ensure-developer-grant'",
16
+ appSlug: "string",
17
+ ownerHandle: "string",
18
+ devHandle: "string",
19
+ devUserId: "string",
20
+ state: DeveloperGrantState,
21
+ updated: "string",
22
+ created: "string",
23
+ });
24
+ export function isResEnsureDeveloperGrant(obj) {
25
+ return !(ResEnsureDeveloperGrant(obj) instanceof type.errors);
26
+ }
27
+ export const ReqRevokeDeveloperGrant = type({
28
+ type: "'vibes.diy.req-revoke-developer-grant'",
29
+ auth: dashAuthType,
30
+ appSlug: "string",
31
+ ownerHandle: "string",
32
+ devHandle: "string",
33
+ });
34
+ export function isReqRevokeDeveloperGrant(obj) {
35
+ return !(ReqRevokeDeveloperGrant(obj) instanceof type.errors);
36
+ }
37
+ export const ResRevokeDeveloperGrant = type({
38
+ type: "'vibes.diy.res-revoke-developer-grant'",
39
+ appSlug: "string",
40
+ ownerHandle: "string",
41
+ devHandle: "string",
42
+ state: "'revoked'",
43
+ updated: "string",
44
+ });
45
+ export function isResRevokeDeveloperGrant(obj) {
46
+ return !(ResRevokeDeveloperGrant(obj) instanceof type.errors);
47
+ }
48
+ export const ReqListDeveloperGrants = type({
49
+ type: "'vibes.diy.req-list-developer-grants'",
50
+ }).and(GrantListBase);
51
+ export function isReqListDeveloperGrants(obj) {
52
+ return !(ReqListDeveloperGrants(obj) instanceof type.errors);
53
+ }
54
+ export const ResListDeveloperGrants = type({
55
+ type: "'vibes.diy.res-list-developer-grants'",
56
+ appSlug: "string",
57
+ ownerHandle: "string",
58
+ items: type({
59
+ devHandle: "string",
60
+ devUserId: "string",
61
+ state: DeveloperGrantState,
62
+ updated: "string",
63
+ created: "string",
64
+ }).array(),
65
+ "nextCursor?": "string",
66
+ });
67
+ export function isResListDeveloperGrants(obj) {
68
+ return !(ResListDeveloperGrants(obj) instanceof type.errors);
69
+ }
70
+ export const ResDeveloperGrantOwnerError = type({
71
+ type: "'vibes.diy.res-error'",
72
+ error: type({ message: "string", code: "'developer-grant-owner-error'" }),
73
+ });
74
+ export function isResDeveloperGrantOwnerError(obj) {
75
+ return !(ResDeveloperGrantOwnerError(obj) instanceof type.errors);
76
+ }
77
+ export const ResDeveloperGrantError = type({
78
+ type: "'vibes.diy.res-error'",
79
+ error: type({
80
+ message: "string",
81
+ code: "'developer-grant-unbound-handle' | 'developer-grant-self-handle' | 'developer-grant-not-found' | 'developer-grant-app-not-found'",
82
+ }),
83
+ });
84
+ export function isResDeveloperGrantError(obj) {
85
+ return !(ResDeveloperGrantError(obj) instanceof type.errors);
86
+ }
87
+ //# sourceMappingURL=developer-grant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"developer-grant.js","sourceRoot":"","sources":["../jsr/developer-grant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAU1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAIhE,MAAM,CAAC,MAAM,uBAAuB,GAA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MAAM,CAAC,CAAC;AACpE,CAAC;AAKD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;IACzC,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,IAAI,CAAC;QACV,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,kIAAkI;KACzI,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,OAAO,CAAC,CAAC,sBAAsB,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function signUnsubscribeToken(userId: string, secret: string): Promise<string>;
2
+ export declare function verifyUnsubscribeToken(userId: string, token: string, secret: string): Promise<boolean>;
3
+ export declare function unsubscribeUrl(baseUrl: string, userId: string, token: string): string;
@@ -0,0 +1,33 @@
1
+ const enc = new TextEncoder();
2
+ async function hmacKey(secret) {
3
+ return crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign", "verify"]);
4
+ }
5
+ function base64Url(bytes) {
6
+ let str = "";
7
+ for (const b of new Uint8Array(bytes))
8
+ str += String.fromCharCode(b);
9
+ return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
10
+ }
11
+ export async function signUnsubscribeToken(userId, secret) {
12
+ const key = await hmacKey(secret);
13
+ const sig = await crypto.subtle.sign("HMAC", key, enc.encode(`unsubscribe:${userId}`));
14
+ return base64Url(sig);
15
+ }
16
+ export async function verifyUnsubscribeToken(userId, token, secret) {
17
+ if (!userId || !token)
18
+ return false;
19
+ const expected = await signUnsubscribeToken(userId, secret);
20
+ if (expected.length !== token.length)
21
+ return false;
22
+ let diff = 0;
23
+ for (let i = 0; i < expected.length; i++)
24
+ diff |= expected.charCodeAt(i) ^ token.charCodeAt(i);
25
+ return diff === 0;
26
+ }
27
+ export function unsubscribeUrl(baseUrl, userId, token) {
28
+ const u = new URL("/email/unsubscribe", baseUrl);
29
+ u.searchParams.set("u", userId);
30
+ u.searchParams.set("t", token);
31
+ return u.toString();
32
+ }
33
+ //# sourceMappingURL=email-unsubscribe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-unsubscribe.js","sourceRoot":"","sources":["../jsr/email-unsubscribe.ts"],"names":[],"mappings":"AAWA,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAE9B,KAAK,UAAU,OAAO,CAAC,MAAc;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1H,CAAC;AAED,SAAS,SAAS,CAAC,KAAkB;IACnC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC;QAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc,EAAE,MAAc;IACvE,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC,CAAC;IACvF,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,CAAC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