@ttt-productions/q-core 0.1.5 → 0.1.6
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.
|
@@ -38,6 +38,13 @@ export declare const AwardGroupGrantSchema: z.ZodObject<{
|
|
|
38
38
|
lastError: z.ZodOptional<z.ZodString>;
|
|
39
39
|
}, z.core.$strict>;
|
|
40
40
|
export type AwardGroupGrant = z.infer<typeof AwardGroupGrantSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a request opens a new decision on an award for a group, given the group's latest decision
|
|
43
|
+
* (`null` when it has none): a grant opens unless the latest is a grant, and a take-back opens only
|
|
44
|
+
* when it is. A request the latest decision already settles opens nothing. The server applies it in
|
|
45
|
+
* the transaction that opens the decision; the admin surface offers only the request it opens.
|
|
46
|
+
*/
|
|
47
|
+
export declare function awardGroupGrantOpens(latest: Pick<AwardGroupGrant, 'action'> | null, action: AwardGroupGrant['action']): boolean;
|
|
41
48
|
export declare const AwardGroupGrantPersonSchema: z.ZodObject<{
|
|
42
49
|
userId: z.ZodString;
|
|
43
50
|
heldBefore: z.ZodBoolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"award-group-grant.d.ts","sourceRoot":"","sources":["../../src/doc-schemas/award-group-grant.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,oBAAoB;;;EAAgC,CAAC;AAClE,eAAO,MAAM,2BAA2B;;;EAAwC,CAAC;AACjF,eAAO,MAAM,2BAA2B;;;EAAwC,CAAC;AAGjF,eAAO,MAAM,6BAA6B,aAAiB,CAAC;AAE5D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;kBA6B9B,CAAC;AACL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"award-group-grant.d.ts","sourceRoot":"","sources":["../../src/doc-schemas/award-group-grant.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,oBAAoB;;;EAAgC,CAAC;AAClE,eAAO,MAAM,2BAA2B;;;EAAwC,CAAC;AACjF,eAAO,MAAM,2BAA2B;;;EAAwC,CAAC;AAGjF,eAAO,MAAM,6BAA6B,aAAiB,CAAC;AAE5D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;kBA6B9B,CAAC;AACL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG,IAAI,EAC9C,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAChC,OAAO,CAET;AAMD,eAAO,MAAM,2BAA2B;;;;;;;;;;kBAOtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -48,6 +48,15 @@ export const AwardGroupGrantSchema = z
|
|
|
48
48
|
ctx.addIssue({ code: 'custom', path: ['grantId'], message: 'grantId must be the target key and the decision.' });
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
+
/**
|
|
52
|
+
* Whether a request opens a new decision on an award for a group, given the group's latest decision
|
|
53
|
+
* (`null` when it has none): a grant opens unless the latest is a grant, and a take-back opens only
|
|
54
|
+
* when it is. A request the latest decision already settles opens nothing. The server applies it in
|
|
55
|
+
* the transaction that opens the decision; the admin surface offers only the request it opens.
|
|
56
|
+
*/
|
|
57
|
+
export function awardGroupGrantOpens(latest, action) {
|
|
58
|
+
return action === 'grant' ? latest?.action !== 'grant' : latest?.action === 'grant';
|
|
59
|
+
}
|
|
51
60
|
// `awardGroupGrants/{grantId}/awardGroupGrantPeople/{userId}` — one person a grant decision reached,
|
|
52
61
|
// recorded before their profile changed. `heldBefore` says they already held the award, so the grant
|
|
53
62
|
// gave them nothing. `revoked` turns true once a revoke has dealt with them; `revokeSkipped` says why
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"award-group-grant.js","sourceRoot":"","sources":["../../src/doc-schemas/award-group-grant.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,gGAAgG;AAChG,sGAAsG;AACtG,kFAAkF;AAClF,EAAE;AACF,sGAAsG;AACtG,wGAAwG;AACxG,wGAAwG;AACxG,oGAAoG;AACpG,6FAA6F;AAE7F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/G,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAClE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AACjF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAEjF,mFAAmF;AACnF,MAAM,CAAC,MAAM,6BAA6B,GAAG,cAAc,CAAC;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,YAAY,CAAC;IACZ,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,MAAM,EAAE,2BAA2B;IACn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CAAC,OAAO,EAAE;IACvB,UAAU,EAAE,aAAa;IACzB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,SAAS,EAAE,aAAa,CAAC,QAAQ,EAAE;IACnC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,QAAQ,EAAE;CAC/D,CAAC,CAAC","sourcesContent":["// `awardGroupGrants/{grantId}` — one decision on one award for one group (a team, or a whole league):\n// grant the award to the group's active members, or take back what the group's grants gave. The\n// people are reached a page at a time, after the decision opens in its own small transaction. Written\n// only by Cloud Functions; an admin reads a decision through the status callable.\n//\n// A grant records each person in `awardGroupGrantPeople` before it changes their profile, so a re-run\n// after any interruption finds every recorded person and finishes them, and its revoke reverses exactly\n// the people it gave the award to. Someone who already held the award is recorded as holding it before,\n// and a revoke leaves them holding it. `status` stays `pending` until every page is done; the retry\n// ledger lets a decision that keeps failing back off instead of holding the resume's window.\n\nimport { z } from 'zod';\nimport { buildAwardGroupGrantId, buildAwardGroupGrantTargetKey } from '../ids/award-grant-ids.js';\nimport {\n AWARD_GROUP_GRANT_ACTION_KEYS,\n AWARD_GROUP_GRANT_STATUS_KEYS,\n AWARD_GROUP_REVOKE_SKIP_KEYS,\n AWARD_GROUP_TYPE_KEYS,\n} from '../types/unions.js';\nimport { countSchema, documentIdSegmentSchema, epochMsSchema, revisionSchema, userIdSchema } from './atoms.js';\nimport { awardIdSchema } from './catalogs.js';\n\nexport const awardGroupTypeSchema = z.enum(AWARD_GROUP_TYPE_KEYS);\nexport const awardGroupGrantActionSchema = z.enum(AWARD_GROUP_GRANT_ACTION_KEYS);\nexport const awardGroupGrantStatusSchema = z.enum(AWARD_GROUP_GRANT_STATUS_KEYS);\n\n// A decision's number among every decision on its award and group: the first is 1.\nexport const awardGroupGrantDecisionSchema = revisionSchema;\n\nexport const AwardGroupGrantSchema = z\n .strictObject({\n grantId: z.string().min(1),\n action: awardGroupGrantActionSchema,\n awardId: awardIdSchema,\n groupType: awardGroupTypeSchema,\n // The team id or the league id, as `groupType` says.\n groupId: documentIdSegmentSchema,\n targetKey: z.string().min(1),\n decision: awardGroupGrantDecisionSchema,\n // The admin who decided. Each person's audit event is recorded as their action.\n actorUid: userIdSchema,\n status: awardGroupGrantStatusSchema,\n createdAt: epochMsSchema,\n completedAt: epochMsSchema.optional(),\n attemptCount: countSchema,\n nextAttemptAt: epochMsSchema,\n lastError: z.string().optional(),\n })\n .superRefine((grant, ctx) => {\n // The key and the id are derived fields: a decision whose stored key or id disagrees with its\n // award, group, and number would sit outside that pair's decision sequence.\n const targetKey = buildAwardGroupGrantTargetKey(grant);\n if (grant.targetKey !== targetKey) {\n ctx.addIssue({ code: 'custom', path: ['targetKey'], message: 'targetKey must be the award and group target key.' });\n }\n if (grant.grantId !== buildAwardGroupGrantId(targetKey, grant.decision)) {\n ctx.addIssue({ code: 'custom', path: ['grantId'], message: 'grantId must be the target key and the decision.' });\n }\n });\nexport type AwardGroupGrant = z.infer<typeof AwardGroupGrantSchema>;\n\n// `awardGroupGrants/{grantId}/awardGroupGrantPeople/{userId}` — one person a grant decision reached,\n// recorded before their profile changed. `heldBefore` says they already held the award, so the grant\n// gave them nothing. `revoked` turns true once a revoke has dealt with them; `revokeSkipped` says why\n// that revoke left them holding the award.\nexport const AwardGroupGrantPersonSchema = z.strictObject({\n userId: userIdSchema,\n heldBefore: z.boolean(),\n recordedAt: epochMsSchema,\n revoked: z.boolean(),\n revokedAt: epochMsSchema.optional(),\n revokeSkipped: z.enum(AWARD_GROUP_REVOKE_SKIP_KEYS).optional(),\n});\nexport type AwardGroupGrantPerson = z.infer<typeof AwardGroupGrantPersonSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"award-group-grant.js","sourceRoot":"","sources":["../../src/doc-schemas/award-group-grant.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,gGAAgG;AAChG,sGAAsG;AACtG,kFAAkF;AAClF,EAAE;AACF,sGAAsG;AACtG,wGAAwG;AACxG,wGAAwG;AACx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,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,QAAQ,EAAE;CAC/D,CAAC,CAAC","sourcesContent":["// `awardGroupGrants/{grantId}` — one decision on one award for one group (a team, or a whole league):\n// grant the award to the group's active members, or take back what the group's grants gave. The\n// people are reached a page at a time, after the decision opens in its own small transaction. Written\n// only by Cloud Functions; an admin reads a decision through the status callable.\n//\n// A grant records each person in `awardGroupGrantPeople` before it changes their profile, so a re-run\n// after any interruption finds every recorded person and finishes them, and its revoke reverses exactly\n// the people it gave the award to. Someone who already held the award is recorded as holding it before,\n// and a revoke leaves them holding it. `status` stays `pending` until every page is done; the retry\n// ledger lets a decision that keeps failing back off instead of holding the resume's window.\n\nimport { z } from 'zod';\nimport { buildAwardGroupGrantId, buildAwardGroupGrantTargetKey } from '../ids/award-grant-ids.js';\nimport {\n AWARD_GROUP_GRANT_ACTION_KEYS,\n AWARD_GROUP_GRANT_STATUS_KEYS,\n AWARD_GROUP_REVOKE_SKIP_KEYS,\n AWARD_GROUP_TYPE_KEYS,\n} from '../types/unions.js';\nimport { countSchema, documentIdSegmentSchema, epochMsSchema, revisionSchema, userIdSchema } from './atoms.js';\nimport { awardIdSchema } from './catalogs.js';\n\nexport const awardGroupTypeSchema = z.enum(AWARD_GROUP_TYPE_KEYS);\nexport const awardGroupGrantActionSchema = z.enum(AWARD_GROUP_GRANT_ACTION_KEYS);\nexport const awardGroupGrantStatusSchema = z.enum(AWARD_GROUP_GRANT_STATUS_KEYS);\n\n// A decision's number among every decision on its award and group: the first is 1.\nexport const awardGroupGrantDecisionSchema = revisionSchema;\n\nexport const AwardGroupGrantSchema = z\n .strictObject({\n grantId: z.string().min(1),\n action: awardGroupGrantActionSchema,\n awardId: awardIdSchema,\n groupType: awardGroupTypeSchema,\n // The team id or the league id, as `groupType` says.\n groupId: documentIdSegmentSchema,\n targetKey: z.string().min(1),\n decision: awardGroupGrantDecisionSchema,\n // The admin who decided. Each person's audit event is recorded as their action.\n actorUid: userIdSchema,\n status: awardGroupGrantStatusSchema,\n createdAt: epochMsSchema,\n completedAt: epochMsSchema.optional(),\n attemptCount: countSchema,\n nextAttemptAt: epochMsSchema,\n lastError: z.string().optional(),\n })\n .superRefine((grant, ctx) => {\n // The key and the id are derived fields: a decision whose stored key or id disagrees with its\n // award, group, and number would sit outside that pair's decision sequence.\n const targetKey = buildAwardGroupGrantTargetKey(grant);\n if (grant.targetKey !== targetKey) {\n ctx.addIssue({ code: 'custom', path: ['targetKey'], message: 'targetKey must be the award and group target key.' });\n }\n if (grant.grantId !== buildAwardGroupGrantId(targetKey, grant.decision)) {\n ctx.addIssue({ code: 'custom', path: ['grantId'], message: 'grantId must be the target key and the decision.' });\n }\n });\nexport type AwardGroupGrant = z.infer<typeof AwardGroupGrantSchema>;\n\n/**\n * Whether a request opens a new decision on an award for a group, given the group's latest decision\n * (`null` when it has none): a grant opens unless the latest is a grant, and a take-back opens only\n * when it is. A request the latest decision already settles opens nothing. The server applies it in\n * the transaction that opens the decision; the admin surface offers only the request it opens.\n */\nexport function awardGroupGrantOpens(\n latest: Pick<AwardGroupGrant, 'action'> | null,\n action: AwardGroupGrant['action'],\n): boolean {\n return action === 'grant' ? latest?.action !== 'grant' : latest?.action === 'grant';\n}\n\n// `awardGroupGrants/{grantId}/awardGroupGrantPeople/{userId}` — one person a grant decision reached,\n// recorded before their profile changed. `heldBefore` says they already held the award, so the grant\n// gave them nothing. `revoked` turns true once a revoke has dealt with them; `revokeSkipped` says why\n// that revoke left them holding the award.\nexport const AwardGroupGrantPersonSchema = z.strictObject({\n userId: userIdSchema,\n heldBefore: z.boolean(),\n recordedAt: epochMsSchema,\n revoked: z.boolean(),\n revokedAt: epochMsSchema.optional(),\n revokeSkipped: z.enum(AWARD_GROUP_REVOKE_SKIP_KEYS).optional(),\n});\nexport type AwardGroupGrantPerson = z.infer<typeof AwardGroupGrantPersonSchema>;\n"]}
|