@vllnt/convex-invitations 0.1.0-canary.01d468e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +139 -0
- package/dist/client/index.d.ts +196 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +181 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +93 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +3 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +40 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +148 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +133 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +80 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +7 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/crons.d.ts +19 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/component/crons.js +22 -0
- package/dist/component/crons.js.map +1 -0
- package/dist/component/mutations.d.ts +118 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +272 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +98 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +93 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +56 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +44 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +49 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +37 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/shared.d.ts +33 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +40 -0
- package/dist/shared.js.map +1 -0
- package/package.json +101 -0
- package/src/client/index.ts +357 -0
- package/src/client/types.ts +98 -0
- package/src/component/_generated/api.ts +56 -0
- package/src/component/_generated/component.ts +179 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +169 -0
- package/src/component/convex.config.ts +9 -0
- package/src/component/crons.ts +26 -0
- package/src/component/mutations.ts +307 -0
- package/src/component/queries.ts +113 -0
- package/src/component/schema.ts +44 -0
- package/src/component/validators.ts +44 -0
- package/src/shared.ts +48 -0
- package/src/test.ts +12 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandboxed table — the invitation's own concern. A `token` is a
|
|
3
|
+
* component-minted single-use secret that names one invitation; the host hands
|
|
4
|
+
* it to the invitee (out of band — email, link) and the invitee redeems it via
|
|
5
|
+
* `accept`. `resourceRef` is the opaque host resource the invite grants access
|
|
6
|
+
* to (an org, a team, a workspace); `role`/`payload` are opaque host data
|
|
7
|
+
* carried through to the host on accept. `state` tracks the lifecycle and
|
|
8
|
+
* `expiresAt` the TTL.
|
|
9
|
+
*
|
|
10
|
+
* Indexes serve token redemption/lookup (`by_token`), the pending-per-resource
|
|
11
|
+
* listing (`by_resource_state`), the TTL expiry sweep over open invites
|
|
12
|
+
* (`by_state_expires`), and the terminal retention sweep
|
|
13
|
+
* (`by_state_created`, oldest-first).
|
|
14
|
+
*
|
|
15
|
+
* The component holds no membership and no real secret store at this minimal
|
|
16
|
+
* stage — it models the invite self-contained. A later version would delegate
|
|
17
|
+
* the hashed/revocable token to `@vllnt/convex-tokens` and write the granted
|
|
18
|
+
* membership via `@vllnt/convex-memberships`; today the `token` lives here and
|
|
19
|
+
* acceptance returns the grant to the host to apply.
|
|
20
|
+
*/
|
|
21
|
+
declare const _default: import("convex/server").SchemaDefinition<{
|
|
22
|
+
invitations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
23
|
+
acceptedAt?: number | undefined;
|
|
24
|
+
acceptedBy?: string | undefined;
|
|
25
|
+
createdAt: number;
|
|
26
|
+
expiresAt: number;
|
|
27
|
+
inviteeRef?: string | undefined;
|
|
28
|
+
inviterRef?: string | undefined;
|
|
29
|
+
payload?: any;
|
|
30
|
+
resourceRef: string;
|
|
31
|
+
revokedAt?: number | undefined;
|
|
32
|
+
role?: any;
|
|
33
|
+
state: "accepted" | "expired" | "pending" | "revoked";
|
|
34
|
+
token: string;
|
|
35
|
+
}, {
|
|
36
|
+
token: import("convex/values").VString<string, "required">;
|
|
37
|
+
resourceRef: import("convex/values").VString<string, "required">;
|
|
38
|
+
role: import("convex/values").VAny<any, "optional", string>;
|
|
39
|
+
inviterRef: import("convex/values").VString<string | undefined, "optional">;
|
|
40
|
+
inviteeRef: import("convex/values").VString<string | undefined, "optional">;
|
|
41
|
+
payload: import("convex/values").VAny<any, "optional", string>;
|
|
42
|
+
state: import("convex/values").VUnion<"accepted" | "expired" | "pending" | "revoked", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"revoked", "required">, import("convex/values").VLiteral<"expired", "required">], "required", never>;
|
|
43
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
44
|
+
expiresAt: import("convex/values").VFloat64<number, "required">;
|
|
45
|
+
acceptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
46
|
+
acceptedBy: import("convex/values").VString<string | undefined, "optional">;
|
|
47
|
+
revokedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
48
|
+
}, "required", "acceptedAt" | "acceptedBy" | "createdAt" | "expiresAt" | "inviteeRef" | "inviterRef" | "payload" | "resourceRef" | "revokedAt" | "role" | "state" | "token" | `payload.${string}` | `role.${string}`>, {
|
|
49
|
+
by_resource_state: ["resourceRef", "state", "createdAt", "_creationTime"];
|
|
50
|
+
by_state_created: ["state", "createdAt", "_creationTime"];
|
|
51
|
+
by_state_expires: ["state", "expiresAt", "_creationTime"];
|
|
52
|
+
by_token: ["token", "_creationTime"];
|
|
53
|
+
}, {}, {}>;
|
|
54
|
+
}, true>;
|
|
55
|
+
export default _default;
|
|
56
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineSchema, defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { invitationState, jsonValue } from "./validators";
|
|
4
|
+
/**
|
|
5
|
+
* Sandboxed table — the invitation's own concern. A `token` is a
|
|
6
|
+
* component-minted single-use secret that names one invitation; the host hands
|
|
7
|
+
* it to the invitee (out of band — email, link) and the invitee redeems it via
|
|
8
|
+
* `accept`. `resourceRef` is the opaque host resource the invite grants access
|
|
9
|
+
* to (an org, a team, a workspace); `role`/`payload` are opaque host data
|
|
10
|
+
* carried through to the host on accept. `state` tracks the lifecycle and
|
|
11
|
+
* `expiresAt` the TTL.
|
|
12
|
+
*
|
|
13
|
+
* Indexes serve token redemption/lookup (`by_token`), the pending-per-resource
|
|
14
|
+
* listing (`by_resource_state`), the TTL expiry sweep over open invites
|
|
15
|
+
* (`by_state_expires`), and the terminal retention sweep
|
|
16
|
+
* (`by_state_created`, oldest-first).
|
|
17
|
+
*
|
|
18
|
+
* The component holds no membership and no real secret store at this minimal
|
|
19
|
+
* stage — it models the invite self-contained. A later version would delegate
|
|
20
|
+
* the hashed/revocable token to `@vllnt/convex-tokens` and write the granted
|
|
21
|
+
* membership via `@vllnt/convex-memberships`; today the `token` lives here and
|
|
22
|
+
* acceptance returns the grant to the host to apply.
|
|
23
|
+
*/
|
|
24
|
+
export default defineSchema({
|
|
25
|
+
invitations: defineTable({
|
|
26
|
+
token: v.string(),
|
|
27
|
+
resourceRef: v.string(),
|
|
28
|
+
role: v.optional(jsonValue),
|
|
29
|
+
inviterRef: v.optional(v.string()),
|
|
30
|
+
inviteeRef: v.optional(v.string()),
|
|
31
|
+
payload: v.optional(jsonValue),
|
|
32
|
+
state: invitationState,
|
|
33
|
+
createdAt: v.number(),
|
|
34
|
+
expiresAt: v.number(),
|
|
35
|
+
acceptedAt: v.optional(v.number()),
|
|
36
|
+
acceptedBy: v.optional(v.string()),
|
|
37
|
+
revokedAt: v.optional(v.number()),
|
|
38
|
+
})
|
|
39
|
+
.index("by_token", ["token"])
|
|
40
|
+
.index("by_resource_state", ["resourceRef", "state", "createdAt"])
|
|
41
|
+
.index("by_state_expires", ["state", "expiresAt"])
|
|
42
|
+
.index("by_state_created", ["state", "createdAt"]),
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAe,YAAY,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;QACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3B,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC9B,KAAK,EAAE,eAAe;QACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAClC,CAAC;SACC,KAAK,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC;SAC5B,KAAK,CAAC,mBAAmB,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;SACjE,KAAK,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACjD,KAAK,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;CACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque host-owned data stored on an invitation — its `role` and its
|
|
3
|
+
* `payload`. The component never inspects either; both are last-resort
|
|
4
|
+
* arbitrary data, aliased here rather than left bare in function signatures.
|
|
5
|
+
* The host narrows them at the {@link Invitations} client boundary via the
|
|
6
|
+
* optional `roleValidator` / `payloadValidator` parsers.
|
|
7
|
+
*
|
|
8
|
+
* This is the single documented `v.any()` escape hatch in the component; the
|
|
9
|
+
* lint rule `convex-rules/no-bare-v-any` is satisfied by routing every arbitrary
|
|
10
|
+
* host payload through this alias instead of a bare `v.any()`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const jsonValue: import("convex/values").VAny<any, "required", string>;
|
|
13
|
+
/** The four lifecycle states an invitation moves through. */
|
|
14
|
+
export declare const invitationState: import("convex/values").VUnion<"accepted" | "expired" | "pending" | "revoked", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"revoked", "required">, import("convex/values").VLiteral<"expired", "required">], "required", never>;
|
|
15
|
+
/**
|
|
16
|
+
* Public projection of an invitation returned by {@link getByToken} and
|
|
17
|
+
* {@link listPending}. `resourceRef`, `inviterRef`, `inviteeRef`, `role`, and
|
|
18
|
+
* `payload` are opaque host data — the component stores and returns them without
|
|
19
|
+
* interpreting them. `token` is the single-use secret the host hands to the
|
|
20
|
+
* invitee; the host gates who may read it.
|
|
21
|
+
*/
|
|
22
|
+
export declare const invitationView: import("convex/values").VObject<{
|
|
23
|
+
acceptedAt?: number | undefined;
|
|
24
|
+
acceptedBy?: string | undefined;
|
|
25
|
+
createdAt: number;
|
|
26
|
+
expiresAt: number;
|
|
27
|
+
inviteeRef?: string | undefined;
|
|
28
|
+
inviterRef?: string | undefined;
|
|
29
|
+
payload?: any;
|
|
30
|
+
resourceRef: string;
|
|
31
|
+
revokedAt?: number | undefined;
|
|
32
|
+
role?: any;
|
|
33
|
+
state: "accepted" | "expired" | "pending" | "revoked";
|
|
34
|
+
token: string;
|
|
35
|
+
}, {
|
|
36
|
+
token: import("convex/values").VString<string, "required">;
|
|
37
|
+
resourceRef: import("convex/values").VString<string, "required">;
|
|
38
|
+
role: import("convex/values").VAny<any, "optional", string>;
|
|
39
|
+
inviterRef: import("convex/values").VString<string | undefined, "optional">;
|
|
40
|
+
inviteeRef: import("convex/values").VString<string | undefined, "optional">;
|
|
41
|
+
payload: import("convex/values").VAny<any, "optional", string>;
|
|
42
|
+
state: import("convex/values").VUnion<"accepted" | "expired" | "pending" | "revoked", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"revoked", "required">, import("convex/values").VLiteral<"expired", "required">], "required", never>;
|
|
43
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
44
|
+
expiresAt: import("convex/values").VFloat64<number, "required">;
|
|
45
|
+
acceptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
46
|
+
acceptedBy: import("convex/values").VString<string | undefined, "optional">;
|
|
47
|
+
revokedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
48
|
+
}, "required", "acceptedAt" | "acceptedBy" | "createdAt" | "expiresAt" | "inviteeRef" | "inviterRef" | "payload" | "resourceRef" | "revokedAt" | "role" | "state" | "token" | `payload.${string}` | `role.${string}`>;
|
|
49
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,uDAAU,CAAC;AAEjC,6DAA6D;AAC7D,eAAO,MAAM,eAAe,0UAK3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;qNAazB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
/**
|
|
3
|
+
* Opaque host-owned data stored on an invitation — its `role` and its
|
|
4
|
+
* `payload`. The component never inspects either; both are last-resort
|
|
5
|
+
* arbitrary data, aliased here rather than left bare in function signatures.
|
|
6
|
+
* The host narrows them at the {@link Invitations} client boundary via the
|
|
7
|
+
* optional `roleValidator` / `payloadValidator` parsers.
|
|
8
|
+
*
|
|
9
|
+
* This is the single documented `v.any()` escape hatch in the component; the
|
|
10
|
+
* lint rule `convex-rules/no-bare-v-any` is satisfied by routing every arbitrary
|
|
11
|
+
* host payload through this alias instead of a bare `v.any()`.
|
|
12
|
+
*/
|
|
13
|
+
export const jsonValue = v.any();
|
|
14
|
+
/** The four lifecycle states an invitation moves through. */
|
|
15
|
+
export const invitationState = v.union(v.literal("pending"), v.literal("accepted"), v.literal("revoked"), v.literal("expired"));
|
|
16
|
+
/**
|
|
17
|
+
* Public projection of an invitation returned by {@link getByToken} and
|
|
18
|
+
* {@link listPending}. `resourceRef`, `inviterRef`, `inviteeRef`, `role`, and
|
|
19
|
+
* `payload` are opaque host data — the component stores and returns them without
|
|
20
|
+
* interpreting them. `token` is the single-use secret the host hands to the
|
|
21
|
+
* invitee; the host gates who may read it.
|
|
22
|
+
*/
|
|
23
|
+
export const invitationView = v.object({
|
|
24
|
+
token: v.string(),
|
|
25
|
+
resourceRef: v.string(),
|
|
26
|
+
role: v.optional(jsonValue),
|
|
27
|
+
inviterRef: v.optional(v.string()),
|
|
28
|
+
inviteeRef: v.optional(v.string()),
|
|
29
|
+
payload: v.optional(jsonValue),
|
|
30
|
+
state: invitationState,
|
|
31
|
+
createdAt: v.number(),
|
|
32
|
+
expiresAt: v.number(),
|
|
33
|
+
acceptedAt: v.optional(v.number()),
|
|
34
|
+
acceptedBy: v.optional(v.string()),
|
|
35
|
+
revokedAt: v.optional(v.number()),
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AAEjC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CACpC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACrB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC9B,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAClC,CAAC,CAAC"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Shared constants used by both `client/` and `component/`. */
|
|
2
|
+
export declare const COMPONENT_NAME = "invitations";
|
|
3
|
+
/**
|
|
4
|
+
* The invitation lifecycle states. `pending` is the freshly-issued, still-open
|
|
5
|
+
* invite; it transitions exactly once into a terminal state — `accepted`
|
|
6
|
+
* (consumed, single-use), `revoked` (cancelled by the host), or `expired`
|
|
7
|
+
* (its TTL elapsed). Terminal states are final — a transition out of one is
|
|
8
|
+
* rejected.
|
|
9
|
+
*/
|
|
10
|
+
export declare const INVITATION_STATES: readonly ["pending", "accepted", "revoked", "expired"];
|
|
11
|
+
/** A single invitation lifecycle state. */
|
|
12
|
+
export type InvitationState = (typeof INVITATION_STATES)[number];
|
|
13
|
+
/** The three terminal states — once reached, an invitation never transitions again. */
|
|
14
|
+
export declare const TERMINAL_STATES: ReadonlySet<InvitationState>;
|
|
15
|
+
/**
|
|
16
|
+
* Default time-to-live (ms) for a freshly-issued invitation: 7 days. A
|
|
17
|
+
* `pending` invite whose `expiresAt` is in the past can no longer be accepted
|
|
18
|
+
* and is swept to `expired` by the prune cron. A host that wants a different
|
|
19
|
+
* window passes `ttlMs` to the {@link Invitations} client (per call or as the
|
|
20
|
+
* construction default), or an absolute `expiresAt` to `issue`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_TTL_MS = 604800000;
|
|
23
|
+
/**
|
|
24
|
+
* Default retention (ms) for terminal invitations before the prune cron sweeps
|
|
25
|
+
* them: 30 days. Bounds unbounded growth of the `invitations` table while
|
|
26
|
+
* leaving a generous window for the host to audit accepted/revoked invites. A
|
|
27
|
+
* host that wants a different window drives `prune` from its own scheduler with
|
|
28
|
+
* an explicit `before` cutoff.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_RETENTION_MS = 2592000000;
|
|
31
|
+
/** Default page size for a `prune` pass before the sweep self-reschedules. */
|
|
32
|
+
export declare const DEFAULT_PRUNE_BATCH = 200;
|
|
33
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,YAC5B,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,CACD,CAAC;AAEX,2CAA2C;AAC3C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,uFAAuF;AACvF,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,eAAe,CAIvD,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,YAAc,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,aAAgB,CAAC;AAElD,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,MAAM,CAAC"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Shared constants used by both `client/` and `component/`. */
|
|
2
|
+
export const COMPONENT_NAME = "invitations";
|
|
3
|
+
/**
|
|
4
|
+
* The invitation lifecycle states. `pending` is the freshly-issued, still-open
|
|
5
|
+
* invite; it transitions exactly once into a terminal state — `accepted`
|
|
6
|
+
* (consumed, single-use), `revoked` (cancelled by the host), or `expired`
|
|
7
|
+
* (its TTL elapsed). Terminal states are final — a transition out of one is
|
|
8
|
+
* rejected.
|
|
9
|
+
*/
|
|
10
|
+
export const INVITATION_STATES = [
|
|
11
|
+
"pending",
|
|
12
|
+
"accepted",
|
|
13
|
+
"revoked",
|
|
14
|
+
"expired",
|
|
15
|
+
];
|
|
16
|
+
/** The three terminal states — once reached, an invitation never transitions again. */
|
|
17
|
+
export const TERMINAL_STATES = new Set([
|
|
18
|
+
"accepted",
|
|
19
|
+
"revoked",
|
|
20
|
+
"expired",
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* Default time-to-live (ms) for a freshly-issued invitation: 7 days. A
|
|
24
|
+
* `pending` invite whose `expiresAt` is in the past can no longer be accepted
|
|
25
|
+
* and is swept to `expired` by the prune cron. A host that wants a different
|
|
26
|
+
* window passes `ttlMs` to the {@link Invitations} client (per call or as the
|
|
27
|
+
* construction default), or an absolute `expiresAt` to `issue`.
|
|
28
|
+
*/
|
|
29
|
+
export const DEFAULT_TTL_MS = 604_800_000;
|
|
30
|
+
/**
|
|
31
|
+
* Default retention (ms) for terminal invitations before the prune cron sweeps
|
|
32
|
+
* them: 30 days. Bounds unbounded growth of the `invitations` table while
|
|
33
|
+
* leaving a generous window for the host to audit accepted/revoked invites. A
|
|
34
|
+
* host that wants a different window drives `prune` from its own scheduler with
|
|
35
|
+
* an explicit `before` cutoff.
|
|
36
|
+
*/
|
|
37
|
+
export const DEFAULT_RETENTION_MS = 2_592_000_000;
|
|
38
|
+
/** Default page size for a `prune` pass before the sweep self-reschedules. */
|
|
39
|
+
export const DEFAULT_PRUNE_BATCH = 200;
|
|
40
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS;IACT,UAAU;IACV,SAAS;IACT,SAAS;CACD,CAAC;AAKX,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAiC,IAAI,GAAG,CAAC;IACnE,UAAU;IACV,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAElD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vllnt/convex-invitations",
|
|
3
|
+
"version": "0.1.0-canary.01d468e",
|
|
4
|
+
"description": "Invite → accept → expire flow — issue a single-use, expiring invitation to a resource and consume it, as a Convex component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "pnpm@9.15.4",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/client/index.d.ts",
|
|
16
|
+
"default": "./dist/client/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./test": "./src/test.ts",
|
|
19
|
+
"./_generated/component.js": {
|
|
20
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./_generated/component": {
|
|
23
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./convex.config": {
|
|
26
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
27
|
+
"default": "./dist/component/convex.config.js"
|
|
28
|
+
},
|
|
29
|
+
"./convex.config.js": {
|
|
30
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
31
|
+
"default": "./dist/component/convex.config.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/client/index.d.ts",
|
|
35
|
+
"module": "./dist/client/index.js",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc --project ./tsconfig.build.json",
|
|
38
|
+
"build:codegen": "pnpm codegen && pnpm build",
|
|
39
|
+
"build:clean": "rm -rf dist *.tsbuildinfo && pnpm build:codegen",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"typecheck:ci": "tsc --noEmit --project tsconfig.ci.json",
|
|
42
|
+
"lint": "pnpm check:agents && eslint .",
|
|
43
|
+
"test": "vitest run --passWithNoTests",
|
|
44
|
+
"test:watch": "vitest --typecheck --clearScreen false",
|
|
45
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text",
|
|
46
|
+
"generate:llms": "node scripts/generate-llms.mjs",
|
|
47
|
+
"preversion": "pnpm install --frozen-lockfile && pnpm build && pnpm test:coverage && pnpm typecheck && pnpm generate:llms",
|
|
48
|
+
"prepublishOnly": "npm whoami || npm login",
|
|
49
|
+
"alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
|
|
50
|
+
"release": "npm version patch && npm publish && git push --follow-tags",
|
|
51
|
+
"check:agents": "node -e \"const f=require('node:fs');if(!f.existsSync('AGENTS.md')||f.existsSync('CLAUDE.md')||f.existsSync('.claude'))process.exit(1)\"",
|
|
52
|
+
"codegen": "pnpm convex codegen --component-dir ./src/component"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"convex": "^1.45.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@edge-runtime/vm": "^5.0.0",
|
|
59
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
61
|
+
"@vllnt/eslint-config": "2.0.0",
|
|
62
|
+
"@vllnt/typescript": "2.0.0",
|
|
63
|
+
"convex": "^1.45.0",
|
|
64
|
+
"convex-test": "^0.0.56",
|
|
65
|
+
"eslint": "^9.39.5",
|
|
66
|
+
"prettier": "^3.9.6",
|
|
67
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
68
|
+
"vite": "^8.2.2",
|
|
69
|
+
"vitest": "^4.1.11"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/vllnt/convex-invitations#readme",
|
|
72
|
+
"bugs": {
|
|
73
|
+
"url": "https://github.com/vllnt/convex-invitations/issues"
|
|
74
|
+
},
|
|
75
|
+
"author": {
|
|
76
|
+
"name": "bntvllnt",
|
|
77
|
+
"url": "https://bntvllnt.com"
|
|
78
|
+
},
|
|
79
|
+
"funding": {
|
|
80
|
+
"type": "github",
|
|
81
|
+
"url": "https://github.com/sponsors/bntvllnt"
|
|
82
|
+
},
|
|
83
|
+
"repository": {
|
|
84
|
+
"type": "git",
|
|
85
|
+
"url": "https://github.com/vllnt/convex-invitations"
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=18"
|
|
89
|
+
},
|
|
90
|
+
"publishConfig": {
|
|
91
|
+
"access": "public"
|
|
92
|
+
},
|
|
93
|
+
"sideEffects": false,
|
|
94
|
+
"keywords": [
|
|
95
|
+
"convex",
|
|
96
|
+
"convex-component",
|
|
97
|
+
"invitations",
|
|
98
|
+
"invite",
|
|
99
|
+
"membership"
|
|
100
|
+
]
|
|
101
|
+
}
|