founder-schema 0.11.0 → 0.12.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.
- package/README.md +65 -0
- package/dist/access/access.d.ts +10 -6
- package/dist/access/access.d.ts.map +1 -1
- package/dist/access/access.js +8 -1
- package/dist/access/access.js.map +1 -1
- package/dist/access/permissions.d.ts +60 -3
- package/dist/access/permissions.d.ts.map +1 -1
- package/dist/access/permissions.js +24 -0
- package/dist/access/permissions.js.map +1 -1
- package/dist/access/roles.d.ts +3 -3
- package/dist/access/standing.d.ts +59 -0
- package/dist/access/standing.d.ts.map +1 -0
- package/dist/access/standing.js +52 -0
- package/dist/access/standing.js.map +1 -0
- package/dist/core/errors.d.ts +47 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +82 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/limits.d.ts +29 -3
- package/dist/core/limits.d.ts.map +1 -1
- package/dist/core/limits.js +30 -3
- package/dist/core/limits.js.map +1 -1
- package/dist/core/responses.d.ts +55 -0
- package/dist/core/responses.d.ts.map +1 -1
- package/dist/core/responses.js +6 -0
- package/dist/core/responses.js.map +1 -1
- package/dist/core/validation.d.ts +14 -0
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +14 -0
- package/dist/core/validation.js.map +1 -1
- package/dist/domains/audit/audit.d.ts +28 -7
- package/dist/domains/audit/audit.d.ts.map +1 -1
- package/dist/domains/audit/audit.js +17 -0
- package/dist/domains/audit/audit.js.map +1 -1
- package/dist/domains/billing/billing.d.ts +1179 -0
- package/dist/domains/billing/billing.d.ts.map +1 -0
- package/dist/domains/billing/billing.js +393 -0
- package/dist/domains/billing/billing.js.map +1 -0
- package/dist/domains/billing/gst.d.ts +229 -0
- package/dist/domains/billing/gst.d.ts.map +1 -0
- package/dist/domains/billing/gst.js +117 -0
- package/dist/domains/billing/gst.js.map +1 -0
- package/dist/domains/chat/chat.d.ts +85 -0
- package/dist/domains/chat/chat.d.ts.map +1 -1
- package/dist/domains/chat/chat.js +62 -0
- package/dist/domains/chat/chat.js.map +1 -1
- package/dist/domains/communities/communities.d.ts +11 -11
- package/dist/domains/dashboard/dashboard.d.ts +9 -1
- package/dist/domains/dashboard/dashboard.d.ts.map +1 -1
- package/dist/domains/dashboard/dashboard.js +15 -0
- package/dist/domains/dashboard/dashboard.js.map +1 -1
- package/dist/domains/feed/feed.d.ts.map +1 -1
- package/dist/domains/feed/feed.js +7 -1
- package/dist/domains/feed/feed.js.map +1 -1
- package/dist/domains/members/members.d.ts +30 -5
- package/dist/domains/members/members.d.ts.map +1 -1
- package/dist/domains/members/members.js +23 -0
- package/dist/domains/members/members.js.map +1 -1
- package/dist/domains/membership/membership.d.ts +239 -0
- package/dist/domains/membership/membership.d.ts.map +1 -0
- package/dist/domains/membership/membership.js +153 -0
- package/dist/domains/membership/membership.js.map +1 -0
- package/dist/domains/notifications/notifications.d.ts +43 -1
- package/dist/domains/notifications/notifications.d.ts.map +1 -1
- package/dist/domains/notifications/notifications.js +19 -0
- package/dist/domains/notifications/notifications.js.map +1 -1
- package/dist/domains/products/products.d.ts +44 -12
- package/dist/domains/products/products.d.ts.map +1 -1
- package/dist/domains/products/products.js +33 -3
- package/dist/domains/products/products.js.map +1 -1
- package/dist/domains/profile/founder-profile.d.ts +1 -1
- package/dist/domains/reviews/reviews.d.ts +3 -0
- package/dist/domains/reviews/reviews.d.ts.map +1 -1
- package/dist/domains/reviews/reviews.js +6 -1
- package/dist/domains/reviews/reviews.js.map +1 -1
- package/dist/domains/team/team.d.ts +4 -4
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -99,6 +99,20 @@ export declare const VALIDATION_MESSAGE: {
|
|
|
99
99
|
readonly communityWithProduct: "communityWithProduct";
|
|
100
100
|
/** The same capability twice in one list (0.9.0). */
|
|
101
101
|
readonly capabilitiesDuplicate: "capabilitiesDuplicate";
|
|
102
|
+
/** Not a GSTIN: 15 characters in its pattern, with a check character that adds up (0.12.0). */
|
|
103
|
+
readonly gstinInvalid: "gstinInvalid";
|
|
104
|
+
/** A GSTIN registered in another state than the one chosen: the state is the GSTIN's own (0.12.0). */
|
|
105
|
+
readonly gstinStateMismatch: "gstinStateMismatch";
|
|
106
|
+
/** A GSTIN without the legal name and address a B2B invoice must carry (0.12.0). */
|
|
107
|
+
readonly gstinNeedsNameAndAddress: "gstinNeedsNameAndAddress";
|
|
108
|
+
/** A coupon code with characters other than letters, digits and hyphens (0.12.0). */
|
|
109
|
+
readonly couponCodeInvalid: "couponCodeInvalid";
|
|
110
|
+
/** A coupon window that ends before it starts (0.12.0). */
|
|
111
|
+
readonly couponWindowInvalid: "couponWindowInvalid";
|
|
112
|
+
/** The same item twice in a coupon's list of what it applies to (0.12.0). */
|
|
113
|
+
readonly couponTargetsDuplicate: "couponTargetsDuplicate";
|
|
114
|
+
/** A paid purchase without the buyer's state: the invoice's place of supply (0.12.0). */
|
|
115
|
+
readonly billingStateRequired: "billingStateRequired";
|
|
102
116
|
};
|
|
103
117
|
export type ValidationMessageKey = (typeof VALIDATION_MESSAGE)[keyof typeof VALIDATION_MESSAGE];
|
|
104
118
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;IAC7B,6BAA6B;;IAE7B,6DAA6D;;IAE7D,2CAA2C;;IAE3C,+BAA+B;;IAE/B,uDAAuD;;IAEvD,6BAA6B;;IAE7B,8DAA8D;;IAE9D,uCAAuC;;IAEvC,wDAAwD;;IAExD,0DAA0D;;IAE1D,0CAA0C;;IAE1C,4CAA4C;;IAE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CAAC,CAAC;AAEhG;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,sCAAuC,CAAC;AACxE,eAAO,MAAM,iBAAiB;;;;EAA8B,CAAC;AAC7D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAkBhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,6EAA6E;AAC7E,UAAU,YAAY;IACpB,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAKD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE;IAAE,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,EAC1C,QAAQ,CAAC,EAAE,WAAW,GACrB,eAAe,EAAE,CAkBnB"}
|
package/dist/core/validation.js
CHANGED
|
@@ -99,6 +99,20 @@ export const VALIDATION_MESSAGE = {
|
|
|
99
99
|
communityWithProduct: 'communityWithProduct',
|
|
100
100
|
/** The same capability twice in one list (0.9.0). */
|
|
101
101
|
capabilitiesDuplicate: 'capabilitiesDuplicate',
|
|
102
|
+
/** Not a GSTIN: 15 characters in its pattern, with a check character that adds up (0.12.0). */
|
|
103
|
+
gstinInvalid: 'gstinInvalid',
|
|
104
|
+
/** A GSTIN registered in another state than the one chosen: the state is the GSTIN's own (0.12.0). */
|
|
105
|
+
gstinStateMismatch: 'gstinStateMismatch',
|
|
106
|
+
/** A GSTIN without the legal name and address a B2B invoice must carry (0.12.0). */
|
|
107
|
+
gstinNeedsNameAndAddress: 'gstinNeedsNameAndAddress',
|
|
108
|
+
/** A coupon code with characters other than letters, digits and hyphens (0.12.0). */
|
|
109
|
+
couponCodeInvalid: 'couponCodeInvalid',
|
|
110
|
+
/** A coupon window that ends before it starts (0.12.0). */
|
|
111
|
+
couponWindowInvalid: 'couponWindowInvalid',
|
|
112
|
+
/** The same item twice in a coupon's list of what it applies to (0.12.0). */
|
|
113
|
+
couponTargetsDuplicate: 'couponTargetsDuplicate',
|
|
114
|
+
/** A paid purchase without the buyer's state: the invoice's place of supply (0.12.0). */
|
|
115
|
+
billingStateRequired: 'billingStateRequired',
|
|
102
116
|
};
|
|
103
117
|
/**
|
|
104
118
|
* Which part of the request an issue is about.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,6BAA6B;IAC7B,SAAS,EAAE,WAAW;IACtB,6DAA6D;IAC7D,eAAe,EAAE,iBAAiB;IAClC,2CAA2C;IAC3C,YAAY,EAAE,cAAc;IAC5B,+BAA+B;IAC/B,WAAW,EAAE,aAAa;IAC1B,uDAAuD;IACvD,UAAU,EAAE,YAAY;IACxB,6BAA6B;IAC7B,WAAW,EAAE,aAAa;IAC1B,8DAA8D;IAC9D,SAAS,EAAE,WAAW;IACtB,uCAAuC;IACvC,iBAAiB,EAAE,mBAAmB;IACtC,wDAAwD;IACxD,gBAAgB,EAAE,kBAAkB;IACpC,0DAA0D;IAC1D,cAAc,EAAE,gBAAgB;IAChC,0CAA0C;IAC1C,SAAS,EAAE,WAAW;IACtB,4CAA4C;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,uEAAuE;IAC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O,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC;QACF,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,OAAO,KAAK,SAAS;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACjD,IAAI,OAAO,KAAK,SAAS;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACjD,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAChE,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAChE,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * founder-schema — How a validation failure is described, on both sides\n *\n * TWO RULES, and they are what let the web client show any error, its own or\n * the server's, on the right field in the member's language:\n *\n * 1. A CUSTOM MESSAGE IS A KEY, NEVER A SENTENCE. Where a schema needs its own\n * message (a refine, a regex), the message is one of `VALIDATION_MESSAGE`,\n * such as `phoneInvalid`. The client turns the key into text in English or\n * Hindi. Before 0.2.0 these were English sentences, so a Hindi screen showed\n * an English error, and a client that wanted to translate one had to match\n * on the wording.\n *\n * Plain bounds carry NO custom message. `.min(1)` and `.max(80)` produce\n * Zod's own `too_small` / `too_big` issues, which already say which bound\n * and what it was (`minimum`, `maximum`, `origin`), and the client words\n * them from those. A hand-written \"at most 80 characters\" would only\n * restate the number in one language.\n *\n * 2. THE SERVER SENDS EVERY ISSUE, IN THIS SHAPE. A 400 answers with\n * `error.details.issues`, built by `toValidationIssues`, so the client can\n * put each one under its field. Until 0.2.0 the backend sent only the\n * first issue's message, with no path at all.\n *\n * ⚠️ `toValidationIssues` COPIES A WHITELIST OF FIELDS, it never spreads an\n * issue. Zod can carry the rejected `input` on an issue, and these bodies hold a\n * date of birth and a phone number. Echoing them into an error response sends\n * them back to the client, into logs and into any proxy in between. A test\n * proves `input` never survives.\n *\n * @module founder-schema/core/validation\n */\n\nimport { z } from 'zod';\n\n/**\n * Every custom message a schema in this package can produce. Each is a\n * translation key the clients define in every language they ship.\n *\n * ⚠️ Append only, and add the translation in the same change. Renaming one\n * shows the raw key to every member until each client ships the new name.\n */\nexport const VALIDATION_MESSAGE = {\n /** Not a 24-hex Mongo id. */\n invalidId: 'invalidId',\n /** Handle: wrong characters, or a dot in the wrong place. */\n usernameInvalid: 'usernameInvalid',\n /** Not a 10-digit Indian mobile number. */\n phoneInvalid: 'phoneInvalid',\n /** Not a `YYYY-MM-DD` date. */\n dateInvalid: 'dateInvalid',\n /** A date that does not exist, such as 30 February. */\n dobInvalid: 'dobInvalid',\n /** Under the minimum age. */\n dobUnderAge: 'dobUnderAge',\n /** Over the sanity ceiling: almost always a mistyped year. */\n dobTooOld: 'dobTooOld',\n /** A founding year after this year. */\n foundedYearFuture: 'foundedYearFuture',\n /** An upload key that is not one this product mints. */\n uploadKeyInvalid: 'uploadKeyInvalid',\n /** The same uploaded image attached twice to one post. */\n mediaDuplicate: 'mediaDuplicate',\n /** A post with neither text nor media. */\n postEmpty: 'postEmpty',\n /** Two poll options with the same label. */\n pollOptionsDuplicate: 'pollOptionsDuplicate',\n /** An empty string sent to clear a patch field; clearing is `null`. */\n clearWithNull: 'clearWithNull',\n /** Not a plain http(s) URL on a real domain (`javascript:`, `localhost`, an IP...). */\n urlInvalid: 'urlInvalid',\n /** A handle this product keeps for itself (`admin`, `support`...). */\n usernameReserved: 'usernameReserved',\n /** Agreed to a version of the guidelines that is not the current one. */\n guidelinesOutdated: 'guidelinesOutdated',\n /** An MPIN that is not exactly six digits. */\n mpinInvalid: 'mpinInvalid',\n /** The MPIN and its confirmation differ. */\n mpinMismatch: 'mpinMismatch',\n /** Switching to a staff role without the MPIN. */\n mpinRequired: 'mpinRequired',\n /** The same role twice in one list. */\n rolesDuplicate: 'rolesDuplicate',\n /** An ask (\"testers wanted\") on a post or poll that names no product. */\n askWithoutProduct: 'askWithoutProduct',\n /** An App Store link that is not on apps.apple.com. */\n appStoreLinkHost: 'appStoreLinkHost',\n /** A Play Store link that is not on play.google.com. */\n playStoreLinkHost: 'playStoreLinkHost',\n /** A GitHub link that is not on github.com. */\n githubLinkHost: 'githubLinkHost',\n /** A demo video that is not a YouTube link. Video is shared, never uploaded. */\n videoLinkHost: 'videoLinkHost',\n /** The same screenshot twice in one gallery. */\n screenshotsDuplicate: 'screenshotsDuplicate',\n /** The same platform twice in one list. */\n platformsDuplicate: 'platformsDuplicate',\n /** The same topic twice in one list (0.9.0). */\n topicsDuplicate: 'topicsDuplicate',\n /** A post or poll in a community naming a product or an ask (0.9.0): community content carries neither. */\n communityWithProduct: 'communityWithProduct',\n /** The same capability twice in one list (0.9.0). */\n capabilitiesDuplicate: 'capabilitiesDuplicate',\n} as const;\nexport type ValidationMessageKey = (typeof VALIDATION_MESSAGE)[keyof typeof VALIDATION_MESSAGE];\n\n/**\n * Which part of the request an issue is about.\n *\n * ONE PATH CONVENTION: `path` is ALWAYS relative to this part, so a body field\n * reads `['venture', 'name']` with `location: 'body'`, never\n * `['body', 'venture', 'name']`. A form maps body issues straight onto its\n * fields without stripping a prefix, and a client that sees `query` or\n * `params` knows the problem is the URL, not anything the member typed.\n */\nexport const REQUEST_PART_VALUES = ['body', 'query', 'params'] as const;\nexport const requestPartSchema = z.enum(REQUEST_PART_VALUES);\nexport type RequestPart = z.infer<typeof requestPartSchema>;\n\n/**\n * One problem with one field, as it crosses the wire.\n *\n * `code` is Zod's issue code (`too_small`, `too_big`, `invalid_type`,\n * `invalid_format`, `custom`...). `message` is either one of\n * `VALIDATION_MESSAGE` or, for a plain bound, Zod's own English text, which the\n * client ignores in favour of `code` plus `minimum` / `maximum`.\n */\nexport const validationIssueSchema = z.object({\n /** Set by the server on every issue it sends; absent on a client's own parse. */\n location: requestPartSchema.optional(),\n /**\n * Where the problem is, RELATIVE TO `location`: `['venture', 'name']`,\n * `['options', 2, 'label']`, `['contentId']`.\n */\n path: z.array(z.union([z.string(), z.number()])),\n code: z.string(),\n message: z.string(),\n /** `too_small`: the bound that was missed. */\n minimum: z.number().optional(),\n /** `too_big`: the bound that was passed. */\n maximum: z.number().optional(),\n /** What was measured: `string`, `array`, `number`... */\n origin: z.string().optional(),\n /** `invalid_format`: which format, e.g. `url`, `regex`, `email`. */\n format: z.string().optional(),\n});\nexport type ValidationIssue = z.infer<typeof validationIssueSchema>;\n\n/** The loosest shape this needs from a Zod issue, so it works across 4.x. */\ninterface ZodIssueLike {\n path: readonly PropertyKey[];\n code: string;\n message: string;\n minimum?: unknown;\n maximum?: unknown;\n origin?: unknown;\n format?: unknown;\n}\n\nconst toNumber = (v: unknown): number | undefined =>\n typeof v === 'number' ? v : typeof v === 'bigint' ? Number(v) : undefined;\n\n/**\n * A Zod error as the wire shape. Use this on the server for every 400, and on\n * the client to treat its own errors and the server's the same way.\n *\n * `location` is stamped on every issue when given; the server always gives it.\n *\n * Copies a WHITELIST of fields (see the module note). A path segment that is a\n * symbol, which JSON cannot carry, becomes its description.\n */\nexport function toValidationIssues(\n error: { issues: readonly ZodIssueLike[] },\n location?: RequestPart,\n): ValidationIssue[] {\n return error.issues.map((issue) => {\n const out: ValidationIssue = {\n ...(location ? { location } : {}),\n path: issue.path.map((p) =>\n typeof p === 'number' ? p : typeof p === 'string' ? p : String(p.description ?? ''),\n ),\n code: issue.code,\n message: issue.message,\n };\n const minimum = toNumber(issue.minimum);\n const maximum = toNumber(issue.maximum);\n if (minimum !== undefined) out.minimum = minimum;\n if (maximum !== undefined) out.maximum = maximum;\n if (typeof issue.origin === 'string') out.origin = issue.origin;\n if (typeof issue.format === 'string') out.format = issue.format;\n return out;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"A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,KAAK,SAAS;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACjD,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAChE,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAChE,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * founder-schema — How a validation failure is described, on both sides\n *\n * TWO RULES, and they are what let the web client show any error, its own or\n * the server's, on the right field in the member's language:\n *\n * 1. A CUSTOM MESSAGE IS A KEY, NEVER A SENTENCE. Where a schema needs its own\n * message (a refine, a regex), the message is one of `VALIDATION_MESSAGE`,\n * such as `phoneInvalid`. The client turns the key into text in English or\n * Hindi. Before 0.2.0 these were English sentences, so a Hindi screen showed\n * an English error, and a client that wanted to translate one had to match\n * on the wording.\n *\n * Plain bounds carry NO custom message. `.min(1)` and `.max(80)` produce\n * Zod's own `too_small` / `too_big` issues, which already say which bound\n * and what it was (`minimum`, `maximum`, `origin`), and the client words\n * them from those. A hand-written \"at most 80 characters\" would only\n * restate the number in one language.\n *\n * 2. THE SERVER SENDS EVERY ISSUE, IN THIS SHAPE. A 400 answers with\n * `error.details.issues`, built by `toValidationIssues`, so the client can\n * put each one under its field. Until 0.2.0 the backend sent only the\n * first issue's message, with no path at all.\n *\n * ⚠️ `toValidationIssues` COPIES A WHITELIST OF FIELDS, it never spreads an\n * issue. Zod can carry the rejected `input` on an issue, and these bodies hold a\n * date of birth and a phone number. Echoing them into an error response sends\n * them back to the client, into logs and into any proxy in between. A test\n * proves `input` never survives.\n *\n * @module founder-schema/core/validation\n */\n\nimport { z } from 'zod';\n\n/**\n * Every custom message a schema in this package can produce. Each is a\n * translation key the clients define in every language they ship.\n *\n * ⚠️ Append only, and add the translation in the same change. Renaming one\n * shows the raw key to every member until each client ships the new name.\n */\nexport const VALIDATION_MESSAGE = {\n /** Not a 24-hex Mongo id. */\n invalidId: 'invalidId',\n /** Handle: wrong characters, or a dot in the wrong place. */\n usernameInvalid: 'usernameInvalid',\n /** Not a 10-digit Indian mobile number. */\n phoneInvalid: 'phoneInvalid',\n /** Not a `YYYY-MM-DD` date. */\n dateInvalid: 'dateInvalid',\n /** A date that does not exist, such as 30 February. */\n dobInvalid: 'dobInvalid',\n /** Under the minimum age. */\n dobUnderAge: 'dobUnderAge',\n /** Over the sanity ceiling: almost always a mistyped year. */\n dobTooOld: 'dobTooOld',\n /** A founding year after this year. */\n foundedYearFuture: 'foundedYearFuture',\n /** An upload key that is not one this product mints. */\n uploadKeyInvalid: 'uploadKeyInvalid',\n /** The same uploaded image attached twice to one post. */\n mediaDuplicate: 'mediaDuplicate',\n /** A post with neither text nor media. */\n postEmpty: 'postEmpty',\n /** Two poll options with the same label. */\n pollOptionsDuplicate: 'pollOptionsDuplicate',\n /** An empty string sent to clear a patch field; clearing is `null`. */\n clearWithNull: 'clearWithNull',\n /** Not a plain http(s) URL on a real domain (`javascript:`, `localhost`, an IP...). */\n urlInvalid: 'urlInvalid',\n /** A handle this product keeps for itself (`admin`, `support`...). */\n usernameReserved: 'usernameReserved',\n /** Agreed to a version of the guidelines that is not the current one. */\n guidelinesOutdated: 'guidelinesOutdated',\n /** An MPIN that is not exactly six digits. */\n mpinInvalid: 'mpinInvalid',\n /** The MPIN and its confirmation differ. */\n mpinMismatch: 'mpinMismatch',\n /** Switching to a staff role without the MPIN. */\n mpinRequired: 'mpinRequired',\n /** The same role twice in one list. */\n rolesDuplicate: 'rolesDuplicate',\n /** An ask (\"testers wanted\") on a post or poll that names no product. */\n askWithoutProduct: 'askWithoutProduct',\n /** An App Store link that is not on apps.apple.com. */\n appStoreLinkHost: 'appStoreLinkHost',\n /** A Play Store link that is not on play.google.com. */\n playStoreLinkHost: 'playStoreLinkHost',\n /** A GitHub link that is not on github.com. */\n githubLinkHost: 'githubLinkHost',\n /** A demo video that is not a YouTube link. Video is shared, never uploaded. */\n videoLinkHost: 'videoLinkHost',\n /** The same screenshot twice in one gallery. */\n screenshotsDuplicate: 'screenshotsDuplicate',\n /** The same platform twice in one list. */\n platformsDuplicate: 'platformsDuplicate',\n /** The same topic twice in one list (0.9.0). */\n topicsDuplicate: 'topicsDuplicate',\n /** A post or poll in a community naming a product or an ask (0.9.0): community content carries neither. */\n communityWithProduct: 'communityWithProduct',\n /** The same capability twice in one list (0.9.0). */\n capabilitiesDuplicate: 'capabilitiesDuplicate',\n /** Not a GSTIN: 15 characters in its pattern, with a check character that adds up (0.12.0). */\n gstinInvalid: 'gstinInvalid',\n /** A GSTIN registered in another state than the one chosen: the state is the GSTIN's own (0.12.0). */\n gstinStateMismatch: 'gstinStateMismatch',\n /** A GSTIN without the legal name and address a B2B invoice must carry (0.12.0). */\n gstinNeedsNameAndAddress: 'gstinNeedsNameAndAddress',\n /** A coupon code with characters other than letters, digits and hyphens (0.12.0). */\n couponCodeInvalid: 'couponCodeInvalid',\n /** A coupon window that ends before it starts (0.12.0). */\n couponWindowInvalid: 'couponWindowInvalid',\n /** The same item twice in a coupon's list of what it applies to (0.12.0). */\n couponTargetsDuplicate: 'couponTargetsDuplicate',\n /** A paid purchase without the buyer's state: the invoice's place of supply (0.12.0). */\n billingStateRequired: 'billingStateRequired',\n} as const;\nexport type ValidationMessageKey = (typeof VALIDATION_MESSAGE)[keyof typeof VALIDATION_MESSAGE];\n\n/**\n * Which part of the request an issue is about.\n *\n * ONE PATH CONVENTION: `path` is ALWAYS relative to this part, so a body field\n * reads `['venture', 'name']` with `location: 'body'`, never\n * `['body', 'venture', 'name']`. A form maps body issues straight onto its\n * fields without stripping a prefix, and a client that sees `query` or\n * `params` knows the problem is the URL, not anything the member typed.\n */\nexport const REQUEST_PART_VALUES = ['body', 'query', 'params'] as const;\nexport const requestPartSchema = z.enum(REQUEST_PART_VALUES);\nexport type RequestPart = z.infer<typeof requestPartSchema>;\n\n/**\n * One problem with one field, as it crosses the wire.\n *\n * `code` is Zod's issue code (`too_small`, `too_big`, `invalid_type`,\n * `invalid_format`, `custom`...). `message` is either one of\n * `VALIDATION_MESSAGE` or, for a plain bound, Zod's own English text, which the\n * client ignores in favour of `code` plus `minimum` / `maximum`.\n */\nexport const validationIssueSchema = z.object({\n /** Set by the server on every issue it sends; absent on a client's own parse. */\n location: requestPartSchema.optional(),\n /**\n * Where the problem is, RELATIVE TO `location`: `['venture', 'name']`,\n * `['options', 2, 'label']`, `['contentId']`.\n */\n path: z.array(z.union([z.string(), z.number()])),\n code: z.string(),\n message: z.string(),\n /** `too_small`: the bound that was missed. */\n minimum: z.number().optional(),\n /** `too_big`: the bound that was passed. */\n maximum: z.number().optional(),\n /** What was measured: `string`, `array`, `number`... */\n origin: z.string().optional(),\n /** `invalid_format`: which format, e.g. `url`, `regex`, `email`. */\n format: z.string().optional(),\n});\nexport type ValidationIssue = z.infer<typeof validationIssueSchema>;\n\n/** The loosest shape this needs from a Zod issue, so it works across 4.x. */\ninterface ZodIssueLike {\n path: readonly PropertyKey[];\n code: string;\n message: string;\n minimum?: unknown;\n maximum?: unknown;\n origin?: unknown;\n format?: unknown;\n}\n\nconst toNumber = (v: unknown): number | undefined =>\n typeof v === 'number' ? v : typeof v === 'bigint' ? Number(v) : undefined;\n\n/**\n * A Zod error as the wire shape. Use this on the server for every 400, and on\n * the client to treat its own errors and the server's the same way.\n *\n * `location` is stamped on every issue when given; the server always gives it.\n *\n * Copies a WHITELIST of fields (see the module note). A path segment that is a\n * symbol, which JSON cannot carry, becomes its description.\n */\nexport function toValidationIssues(\n error: { issues: readonly ZodIssueLike[] },\n location?: RequestPart,\n): ValidationIssue[] {\n return error.issues.map((issue) => {\n const out: ValidationIssue = {\n ...(location ? { location } : {}),\n path: issue.path.map((p) =>\n typeof p === 'number' ? p : typeof p === 'string' ? p : String(p.description ?? ''),\n ),\n code: issue.code,\n message: issue.message,\n };\n const minimum = toNumber(issue.minimum);\n const maximum = toNumber(issue.maximum);\n if (minimum !== undefined) out.minimum = minimum;\n if (maximum !== undefined) out.maximum = maximum;\n if (typeof issue.origin === 'string') out.origin = issue.origin;\n if (typeof issue.format === 'string') out.format = issue.format;\n return out;\n });\n}\n"]}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @module founder-schema/domains/audit
|
|
23
23
|
*/
|
|
24
24
|
import { z } from 'zod';
|
|
25
|
-
export declare const AUDIT_ACTION_VALUES: readonly ["role.granted", "role.revoked", "mpin.cleared", "content.removed", "content.hidden", "content.restored", "report.dismissed", "member.suspended", "member.unsuspended", "ticket.claimed", "ticket.resolved", "capability.granted", "capability.revoked", "community.created", "community.visibility_changed", "community.archived", "community.restored", "community.deleted", "community_suggestion.declined", "community.orphaned"];
|
|
25
|
+
export declare const AUDIT_ACTION_VALUES: readonly ["role.granted", "role.revoked", "mpin.cleared", "content.removed", "content.hidden", "content.restored", "report.dismissed", "member.suspended", "member.unsuspended", "ticket.claimed", "ticket.resolved", "capability.granted", "capability.revoked", "community.created", "community.visibility_changed", "community.archived", "community.restored", "community.deleted", "community_suggestion.declined", "community.orphaned", "membership.granted", "membership.revoked", "payment.refunded", "coupon.created", "coupon.updated"];
|
|
26
26
|
export declare const auditActionSchema: z.ZodEnum<{
|
|
27
27
|
"role.granted": "role.granted";
|
|
28
28
|
"role.revoked": "role.revoked";
|
|
@@ -44,6 +44,11 @@ export declare const auditActionSchema: z.ZodEnum<{
|
|
|
44
44
|
"community.deleted": "community.deleted";
|
|
45
45
|
"community_suggestion.declined": "community_suggestion.declined";
|
|
46
46
|
"community.orphaned": "community.orphaned";
|
|
47
|
+
"membership.granted": "membership.granted";
|
|
48
|
+
"membership.revoked": "membership.revoked";
|
|
49
|
+
"payment.refunded": "payment.refunded";
|
|
50
|
+
"coupon.created": "coupon.created";
|
|
51
|
+
"coupon.updated": "coupon.updated";
|
|
47
52
|
}>;
|
|
48
53
|
export type AuditAction = z.infer<typeof auditActionSchema>;
|
|
49
54
|
/**
|
|
@@ -56,11 +61,11 @@ export declare const auditActorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
56
61
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
57
62
|
displayName: z.ZodString;
|
|
58
63
|
actingAs: z.ZodEnum<{
|
|
64
|
+
moderator: "moderator";
|
|
59
65
|
superadmin: "superadmin";
|
|
66
|
+
member: "member";
|
|
60
67
|
manager: "manager";
|
|
61
|
-
moderator: "moderator";
|
|
62
68
|
support_agent: "support_agent";
|
|
63
|
-
member: "member";
|
|
64
69
|
}>;
|
|
65
70
|
}, z.core.$strip>, z.ZodObject<{
|
|
66
71
|
kind: z.ZodLiteral<"script">;
|
|
@@ -78,11 +83,11 @@ export declare const auditEntrySchema: z.ZodObject<{
|
|
|
78
83
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
79
84
|
displayName: z.ZodString;
|
|
80
85
|
actingAs: z.ZodEnum<{
|
|
86
|
+
moderator: "moderator";
|
|
81
87
|
superadmin: "superadmin";
|
|
88
|
+
member: "member";
|
|
82
89
|
manager: "manager";
|
|
83
|
-
moderator: "moderator";
|
|
84
90
|
support_agent: "support_agent";
|
|
85
|
-
member: "member";
|
|
86
91
|
}>;
|
|
87
92
|
}, z.core.$strip>, z.ZodObject<{
|
|
88
93
|
kind: z.ZodLiteral<"script">;
|
|
@@ -113,6 +118,11 @@ export declare const auditEntrySchema: z.ZodObject<{
|
|
|
113
118
|
"community.deleted": "community.deleted";
|
|
114
119
|
"community_suggestion.declined": "community_suggestion.declined";
|
|
115
120
|
"community.orphaned": "community.orphaned";
|
|
121
|
+
"membership.granted": "membership.granted";
|
|
122
|
+
"membership.revoked": "membership.revoked";
|
|
123
|
+
"payment.refunded": "payment.refunded";
|
|
124
|
+
"coupon.created": "coupon.created";
|
|
125
|
+
"coupon.updated": "coupon.updated";
|
|
116
126
|
}>;
|
|
117
127
|
target: z.ZodObject<{
|
|
118
128
|
subject: z.ZodEnum<{
|
|
@@ -133,6 +143,9 @@ export declare const auditEntrySchema: z.ZodObject<{
|
|
|
133
143
|
Review: "Review";
|
|
134
144
|
Community: "Community";
|
|
135
145
|
CommunitySuggestion: "CommunitySuggestion";
|
|
146
|
+
Membership: "Membership";
|
|
147
|
+
Payment: "Payment";
|
|
148
|
+
Coupon: "Coupon";
|
|
136
149
|
}>;
|
|
137
150
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
138
151
|
label: z.ZodNullable<z.ZodString>;
|
|
@@ -149,11 +162,11 @@ export declare const auditPageSchema: z.ZodObject<{
|
|
|
149
162
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
150
163
|
displayName: z.ZodString;
|
|
151
164
|
actingAs: z.ZodEnum<{
|
|
165
|
+
moderator: "moderator";
|
|
152
166
|
superadmin: "superadmin";
|
|
167
|
+
member: "member";
|
|
153
168
|
manager: "manager";
|
|
154
|
-
moderator: "moderator";
|
|
155
169
|
support_agent: "support_agent";
|
|
156
|
-
member: "member";
|
|
157
170
|
}>;
|
|
158
171
|
}, z.core.$strip>, z.ZodObject<{
|
|
159
172
|
kind: z.ZodLiteral<"script">;
|
|
@@ -184,6 +197,11 @@ export declare const auditPageSchema: z.ZodObject<{
|
|
|
184
197
|
"community.deleted": "community.deleted";
|
|
185
198
|
"community_suggestion.declined": "community_suggestion.declined";
|
|
186
199
|
"community.orphaned": "community.orphaned";
|
|
200
|
+
"membership.granted": "membership.granted";
|
|
201
|
+
"membership.revoked": "membership.revoked";
|
|
202
|
+
"payment.refunded": "payment.refunded";
|
|
203
|
+
"coupon.created": "coupon.created";
|
|
204
|
+
"coupon.updated": "coupon.updated";
|
|
187
205
|
}>;
|
|
188
206
|
target: z.ZodObject<{
|
|
189
207
|
subject: z.ZodEnum<{
|
|
@@ -204,6 +222,9 @@ export declare const auditPageSchema: z.ZodObject<{
|
|
|
204
222
|
Review: "Review";
|
|
205
223
|
Community: "Community";
|
|
206
224
|
CommunitySuggestion: "CommunitySuggestion";
|
|
225
|
+
Membership: "Membership";
|
|
226
|
+
Payment: "Payment";
|
|
227
|
+
Coupon: "Coupon";
|
|
207
228
|
}>;
|
|
208
229
|
id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
209
230
|
label: z.ZodNullable<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../src/domains/audit/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../src/domains/audit/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,mBAAmB,ohBAmEtB,CAAC;AACX,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;EAA8B,CAAC;AAC7D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;2BAyB3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAS3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAoC,CAAC;AACjE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -76,6 +76,23 @@ export const AUDIT_ACTION_VALUES = [
|
|
|
76
76
|
* kind `script`); managers then make a member admin.
|
|
77
77
|
*/
|
|
78
78
|
'community.orphaned',
|
|
79
|
+
/** Staff gave someone a membership (0.12.0). `detail.reason`. Target subject `Membership`. */
|
|
80
|
+
'membership.granted',
|
|
81
|
+
/**
|
|
82
|
+
* Staff took a founding, coupon or granted membership away (0.12.0): a fake
|
|
83
|
+
* or duplicate account. `detail.reason`, `detail.kind`. A paid one is
|
|
84
|
+
* refunded instead (`payment.refunded`).
|
|
85
|
+
*/
|
|
86
|
+
'membership.revoked',
|
|
87
|
+
/**
|
|
88
|
+
* Staff refunded a payment (0.12.0). `detail.reason`, `detail.amount`
|
|
89
|
+
* (paise), `detail.item`. Target subject `Payment`.
|
|
90
|
+
*/
|
|
91
|
+
'payment.refunded',
|
|
92
|
+
/** Staff created a coupon (0.12.0). `detail.code`, `detail.benefit`, `detail.max`. */
|
|
93
|
+
'coupon.created',
|
|
94
|
+
/** Staff changed a coupon (0.12.0): switched it off or on, its cap, window or label. `detail.changes`. */
|
|
95
|
+
'coupon.updated',
|
|
79
96
|
];
|
|
80
97
|
export const auditActionSchema = z.enum(AUDIT_ACTION_VALUES);
|
|
81
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/domains/audit/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kDAAkD;IAClD,cAAc;IACd,qDAAqD;IACrD,cAAc;IACd,uEAAuE;IACvE,cAAc;IACd,gGAAgG;IAChG,iBAAiB;IACjB;;;;;OAKG;IACH,gBAAgB;IAChB,uGAAuG;IACvG,kBAAkB;IAClB,2FAA2F;IAC3F,kBAAkB;IAClB,gEAAgE;IAChE,kBAAkB;IAClB,+BAA+B;IAC/B,oBAAoB;IACpB,qCAAqC;IACrC,gBAAgB;IAChB,mDAAmD;IACnD,iBAAiB;IACjB,6DAA6D;IAC7D,oBAAoB;IACpB,gEAAgE;IAChE,oBAAoB;IACpB,0GAA0G;IAC1G,mBAAmB;IACnB,wFAAwF;IACxF,8BAA8B;IAC9B,0CAA0C;IAC1C,oBAAoB;IACpB,oDAAoD;IACpD,oBAAoB;IACpB,yCAAyC;IACzC,mBAAmB;IACnB,wGAAwG;IACxG,+BAA+B;IAC/B;;;;OAIG;IACH,oBAAoB;
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/domains/audit/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kDAAkD;IAClD,cAAc;IACd,qDAAqD;IACrD,cAAc;IACd,uEAAuE;IACvE,cAAc;IACd,gGAAgG;IAChG,iBAAiB;IACjB;;;;;OAKG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O,CAAC,QAAQ,CAAC;QACzB,EAAE,EAAE,cAAc;QAClB,mCAAmC;QACnC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;KACxB,CAAC;CACH,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,cAAc;IAClB,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,iBAAiB;IACzB,6EAA6E;IAC7E,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC9F,mFAAmF;IACnF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACtF,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;CACrB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/**\n * founder-schema: the audit log\n *\n * GET /api/v1/audit staff actions, newest first\n *\n * Every action a staff member takes on a MEMBER or on what a member wrote\n * (roles, MPIN resets, suspensions, moderation decisions, taking and closing\n * tickets) is written here, at the moment it happens, by the server: who did\n * it, AS WHICH ROLE, what they did, to what, and anything that explains it.\n * The support team's own library (saved replies) is not a member's, so its\n * edits are not entries. Entries are never edited or\n * deleted. It is how a dispute (\"who removed my post, and why\") gets an\n * answer, and how a misused staff account is noticed.\n *\n * WHO READS WHAT is the reader's permissions, applied to the query: a\n * superadmin reads every entry; any other staff role reads the entries it\n * wrote itself (its History).\n *\n * The action list grows with the staff features; it never shrinks, because an\n * old entry must still parse.\n *\n * @module founder-schema/domains/audit\n */\n\nimport { z } from 'zod';\nimport { subjectSchema } from '../../access/permissions.js';\nimport { roleSchema } from '../../access/roles.js';\nimport { objectIdSchema } from '../../core/common.js';\nimport { paginatedSchema } from '../../core/responses.js';\n\nexport const AUDIT_ACTION_VALUES = [\n /** A platform role was granted. `detail.role`. */\n 'role.granted',\n /** A platform role was taken away. `detail.role`. */\n 'role.revoked',\n /** Someone's forgotten MPIN was cleared, so they can set a new one. */\n 'mpin.cleared',\n /** Staff removed someone else's post, poll, comment or review (`target.subject` says which). */\n 'content.removed',\n /**\n * Staff hid a post, poll, comment, product or review: out of every feed and\n * list, restorable. `detail.note`. Since 0.9.0 also a community's\n * moderators hiding a post, poll or comment in it (actor kind `member`, or\n * staff), with `detail.communityId`.\n */\n 'content.hidden',\n /** Hidden content (a product or review too) put back, by staff or (0.9.0) a community's moderators. */\n 'content.restored',\n /** Staff looked at what was reported and left it up. `detail.reports`: how many closed. */\n 'report.dismissed',\n /** A member was suspended from the product. `detail.reason`. */\n 'member.suspended',\n /** A suspension was lifted. */\n 'member.unsuspended',\n /** A support agent took a ticket. */\n 'ticket.claimed',\n /** A support agent closed a ticket as resolved. */\n 'ticket.resolved',\n /** A capability was granted (0.9.0). `detail.capability`. */\n 'capability.granted',\n /** A capability was taken away (0.9.0). `detail.capability`. */\n 'capability.revoked',\n /** A community was created (0.9.0). `detail.visibility`; `detail.suggestionId` when from a suggestion. */\n 'community.created',\n /** A community's type changed (0.9.0). `detail.from`, `detail.to`, `detail.exposed`. */\n 'community.visibility_changed',\n /** Staff archived a community (0.9.0). */\n 'community.archived',\n /** Staff restored an archived community (0.9.0). */\n 'community.restored',\n /** Staff deleted a community (0.9.0). */\n 'community.deleted',\n /** Staff declined a community suggestion (0.9.0). `detail.reason`. Approving is `community.created`. */\n 'community_suggestion.declined',\n /**\n * A community was left with no admin (0.9.0): its last admin's account was\n * deleted where that cannot be refused. Written by the deletion (actor\n * kind `script`); managers then make a member admin.\n */\n 'community.orphaned',\n /** Staff gave someone a membership (0.12.0). `detail.reason`. Target subject `Membership`. */\n 'membership.granted',\n /**\n * Staff took a founding, coupon or granted membership away (0.12.0): a fake\n * or duplicate account. `detail.reason`, `detail.kind`. A paid one is\n * refunded instead (`payment.refunded`).\n */\n 'membership.revoked',\n /**\n * Staff refunded a payment (0.12.0). `detail.reason`, `detail.amount`\n * (paise), `detail.item`. Target subject `Payment`.\n */\n 'payment.refunded',\n /** Staff created a coupon (0.12.0). `detail.code`, `detail.benefit`, `detail.max`. */\n 'coupon.created',\n /** Staff changed a coupon (0.12.0): switched it off or on, its cap, window or label. `detail.changes`. */\n 'coupon.updated',\n] as const;\nexport const auditActionSchema = z.enum(AUDIT_ACTION_VALUES);\nexport type AuditAction = z.infer<typeof auditActionSchema>;\n\n/**\n * Who did it. A person, acting as one of their roles; a server script, which\n * is the only way a superadmin is ever made; or (0.9.0) a member acting in a\n * community they run, who is not staff.\n */\nexport const auditActorSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('staff'),\n id: objectIdSchema,\n /** Their name when they did it. An entry is a record, so it is not renamed later. */\n displayName: z.string(),\n /** The role they were acting as. */\n actingAs: roleSchema,\n }),\n z.object({\n kind: z.literal('script'),\n /** Which script, e.g. `grant-superadmin`. */\n name: z.string(),\n }),\n /**\n * A member who is not acting as staff (0.9.0): a community's admin changing\n * its type, say. Its own kind, so nobody reading the log mistakes a\n * community admin for staff.\n */\n z.object({\n kind: z.literal('member'),\n id: objectIdSchema,\n /** Their name when they did it. */\n displayName: z.string(),\n }),\n]);\nexport type AuditActor = z.infer<typeof auditActorSchema>;\n\nexport const auditEntrySchema = z.object({\n id: objectIdSchema,\n actor: auditActorSchema,\n action: auditActionSchema,\n /** What it was done to. `label` is its name at the time, when it has one. */\n target: z.object({ subject: subjectSchema, id: objectIdSchema, label: z.string().nullable() }),\n /** The specifics, by action (the role granted, a reason given). Never a secret. */\n detail: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),\n at: z.iso.datetime(),\n});\nexport type AuditEntry = z.infer<typeof auditEntrySchema>;\n\nexport const auditPageSchema = paginatedSchema(auditEntrySchema);\nexport type AuditPage = z.infer<typeof auditPageSchema>;\n"]}
|