@singi-labs/sifa-sdk 0.12.0 → 0.12.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.
@@ -0,0 +1,164 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/schemas/write/shared.ts
4
+ function normalizeUrl(val) {
5
+ const trimmed = val.trim();
6
+ if (/^https?:\/\//i.test(trimmed)) return trimmed;
7
+ return `https://${trimmed}`;
8
+ }
9
+ var optionalUrl = () => z.string().optional().transform((val) => {
10
+ if (!val) return void 0;
11
+ try {
12
+ new URL(val);
13
+ return val;
14
+ } catch {
15
+ return void 0;
16
+ }
17
+ });
18
+ var writeLocationSchema = z.union([
19
+ z.object({
20
+ country: z.string().nullish(),
21
+ countryCode: z.string().length(2).nullish(),
22
+ region: z.string().nullish(),
23
+ city: z.string().nullish(),
24
+ locality: z.string().nullish(),
25
+ street: z.string().nullish(),
26
+ postalCode: z.string().nullish(),
27
+ name: z.string().nullish()
28
+ }),
29
+ z.string()
30
+ ]).nullable().optional();
31
+ var skillRefSchema = z.object({
32
+ uri: z.string()
33
+ });
34
+ var VALID_PLATFORMS = [
35
+ "rss",
36
+ "fediverse",
37
+ "twitter",
38
+ "instagram",
39
+ "github",
40
+ "codeberg",
41
+ "gitlab",
42
+ "forgejo",
43
+ "gitea",
44
+ "youtube",
45
+ "linkedin",
46
+ "substack",
47
+ "website",
48
+ "orcid",
49
+ "keyoxide",
50
+ "other"
51
+ ];
52
+ var CertificationWriteSchema = z.object({
53
+ name: z.string().min(1).max(256),
54
+ authority: z.string().max(256).nullable().optional(),
55
+ credentialId: z.string().max(256).nullable().optional(),
56
+ credentialUrl: optionalUrl(),
57
+ issuedAt: z.string().nullable().optional(),
58
+ expiresAt: z.string().nullable().optional()
59
+ });
60
+ var CourseWriteSchema = z.object({
61
+ name: z.string().min(1).max(200),
62
+ number: z.string().max(50).nullable().optional(),
63
+ institution: z.string().max(256).nullable().optional()
64
+ });
65
+ var EducationWriteSchema = z.object({
66
+ institution: z.string().min(1).max(256),
67
+ degree: z.string().max(256).nullable().optional(),
68
+ fieldOfStudy: z.string().max(256).nullable().optional(),
69
+ description: z.string().max(5e4).nullable().optional(),
70
+ activities: z.string().max(1e3).nullable().optional(),
71
+ startedAt: z.string().nullable().optional(),
72
+ endedAt: z.string().nullable().optional()
73
+ });
74
+ var ExternalAccountWriteSchema = z.object({
75
+ platform: z.enum(VALID_PLATFORMS),
76
+ url: z.string().max(2e3).transform(normalizeUrl).pipe(z.string().url()),
77
+ label: z.string().max(100).optional(),
78
+ feedUrl: z.string().max(2e3).transform(normalizeUrl).pipe(z.string().url()).optional()
79
+ });
80
+ var HonorWriteSchema = z.object({
81
+ title: z.string().min(1).max(200),
82
+ issuer: z.string().max(256).nullable().optional(),
83
+ description: z.string().max(5e4).nullable().optional(),
84
+ awardedAt: z.string().nullable().optional()
85
+ });
86
+ var LanguageWriteSchema = z.object({
87
+ name: z.string().min(1).max(64),
88
+ proficiency: z.string().max(50).optional()
89
+ });
90
+ var PositionWriteSchema = z.object({
91
+ company: z.string().min(1).max(256).nullable().optional(),
92
+ title: z.string().min(1).max(256),
93
+ description: z.string().max(5e4).nullable().optional(),
94
+ employmentType: z.string().nullable().optional(),
95
+ workplaceType: z.string().nullable().optional(),
96
+ location: writeLocationSchema,
97
+ startedAt: z.string().nullable().optional(),
98
+ endedAt: z.string().nullable().optional(),
99
+ skills: z.array(skillRefSchema).max(50).nullable().optional()
100
+ });
101
+ var ProfileLocationWriteSchema = z.object({
102
+ address: z.object({
103
+ country: z.string().nullish(),
104
+ countryCode: z.string().length(2).nullish(),
105
+ region: z.string().nullish(),
106
+ city: z.string().nullish(),
107
+ locality: z.string().nullish(),
108
+ street: z.string().nullish(),
109
+ postalCode: z.string().nullish(),
110
+ name: z.string().nullish()
111
+ }),
112
+ type: z.string().min(1),
113
+ label: z.string().max(60).nullable().optional(),
114
+ isPrimary: z.boolean().optional()
115
+ });
116
+ var ProfileSelfWriteSchema = z.object({
117
+ headline: z.string().max(300).optional(),
118
+ about: z.string().max(5e4).optional(),
119
+ givenName: z.string().max(640).optional(),
120
+ familyName: z.string().max(640).optional(),
121
+ industries: z.array(
122
+ z.object({
123
+ industry: z.string().max(100),
124
+ domain: z.string().max(100).optional()
125
+ })
126
+ ).max(10).optional(),
127
+ location: writeLocationSchema,
128
+ openTo: z.array(z.string()).max(10).optional(),
129
+ preferredWorkplace: z.array(z.string()).max(5).optional(),
130
+ availableFromUtc: z.number().int().min(0).max(23).optional(),
131
+ availableToUtc: z.number().int().min(0).max(23).optional(),
132
+ langs: z.array(z.string()).max(3).optional(),
133
+ discoverable: z.boolean().optional()
134
+ }).passthrough();
135
+ var ProjectWriteSchema = z.object({
136
+ name: z.string().min(1).max(256),
137
+ description: z.string().max(5e4).nullable().optional(),
138
+ url: optionalUrl(),
139
+ startedAt: z.string().nullable().optional(),
140
+ endedAt: z.string().nullable().optional()
141
+ });
142
+ var PublicationWriteSchema = z.object({
143
+ title: z.string().min(1).max(200),
144
+ publisher: z.string().max(256).nullable().optional(),
145
+ url: optionalUrl(),
146
+ description: z.string().max(5e4).nullable().optional(),
147
+ publishedAt: z.string().nullable().optional()
148
+ });
149
+ var SkillWriteSchema = z.object({
150
+ name: z.string().min(1).max(100),
151
+ category: z.string().max(100).optional()
152
+ });
153
+ var VolunteeringWriteSchema = z.object({
154
+ organization: z.string().min(1).max(256),
155
+ role: z.string().max(256).nullable().optional(),
156
+ cause: z.string().max(256).nullable().optional(),
157
+ description: z.string().max(5e4).nullable().optional(),
158
+ startedAt: z.string().nullable().optional(),
159
+ endedAt: z.string().nullable().optional()
160
+ });
161
+
162
+ export { CertificationWriteSchema, CourseWriteSchema, EducationWriteSchema, ExternalAccountWriteSchema, HonorWriteSchema, LanguageWriteSchema, PositionWriteSchema, ProfileLocationWriteSchema, ProfileSelfWriteSchema, ProjectWriteSchema, PublicationWriteSchema, SkillWriteSchema, VALID_PLATFORMS, VolunteeringWriteSchema, normalizeUrl, optionalUrl, skillRefSchema, writeLocationSchema };
163
+ //# sourceMappingURL=index.js.map
164
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/schemas/write/shared.ts","../../../src/schemas/write/certification.ts","../../../src/schemas/write/course.ts","../../../src/schemas/write/education.ts","../../../src/schemas/write/external-account.ts","../../../src/schemas/write/honor.ts","../../../src/schemas/write/language.ts","../../../src/schemas/write/position.ts","../../../src/schemas/write/profile-location.ts","../../../src/schemas/write/profile-self.ts","../../../src/schemas/write/project.ts","../../../src/schemas/write/publication.ts","../../../src/schemas/write/skill.ts","../../../src/schemas/write/volunteering.ts"],"names":["z"],"mappings":";;;AAGO,SAAS,aAAa,GAAA,EAAqB;AAChD,EAAA,MAAM,OAAA,GAAU,IAAI,IAAA,EAAK;AACzB,EAAA,IAAI,eAAA,CAAgB,IAAA,CAAK,OAAO,CAAA,EAAG,OAAO,OAAA;AAC1C,EAAA,OAAO,WAAW,OAAO,CAAA,CAAA;AAC3B;AAMO,IAAM,WAAA,GAAc,MACzB,CAAA,CACG,MAAA,GACA,QAAA,EAAS,CACT,SAAA,CAAU,CAAC,GAAA,KAAQ;AAClB,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,IAAI;AACF,IAAA,IAAI,IAAI,GAAG,CAAA;AACX,IAAA,OAAO,GAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF,CAAC;AAiBE,IAAM,mBAAA,GAAsB,EAChC,KAAA,CAAM;AAAA,EACL,EAAE,MAAA,CAAO;AAAA,IACP,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,OAAA,EAAQ;AAAA,IAC5B,aAAa,CAAA,CAAE,MAAA,GAAS,MAAA,CAAO,CAAC,EAAE,OAAA,EAAQ;AAAA,IAC1C,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,OAAA,EAAQ;AAAA,IAC3B,IAAA,EAAM,CA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AA,EAAWA,EAAE,MAAA,EAAO,CAAE,IAAI,GAAG,CAAA,CAAE,QAAA,EAAS,CAAE,QAAA,EAAS;AAAA,EACnD,KAAK,WAAA,EAAY;AAAA,EACjB,WAAA,EAAaA,EAAE,MAAA,EAAO,CAAE,IAAI,GAAK,CAAA,CAAE,QAAA,EAAS,CAAE,QAAA,EAAS;AAAA,EACvD,aAAaA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA;AACrC,CAAC;ACRM,IAAM,gBAAA,GAAmBA,EAAE,MAAA,CAAO;AAAA,EACvC,IAAA,EAAMA,EAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA,CAAE,IAAI,GAAG,CAAA;AAAA,EAC/B,UAAUA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA;AAChC,CAAC;ACHM,IAAM,uBAAA,GAA0BA,EAAE,MAAA,CAAO;AAAA,EAC9C,YAAA,EAAcA,EAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA,CAAE,IAAI,GAAG,CAAA;AAAA,EACvC,IAAA,EAAMA,EAAE,MAAA,EAAO,CAAE,IAAI,GAAG,CAAA,CAAE,QAAA,EAAS,CAAE,QAAA,EAAS;AAAA,EAC9C,KAAA,EAAOA,EAAE,MAAA,EAAO,CAAE,IAAI,GAAG,CAAA,CAAE,QAAA,EAAS,CAAE,QAAA,EAAS;AAAA,EAC/C,WAAA,EAAaA,EAAE,MAAA,EAAO,CAAE,IAAI,GAAK,CAAA,CAAE,QAAA,EAAS,CAAE,QAAA,EAAS;AAAA,EACvD,WAAWA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA,EAAS;AAAA,EAC1C,SAASA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA;AACjC,CAAC","file":"index.js","sourcesContent":["import { z } from 'zod';\n\n/** Prepend `https://` if no scheme is present. */\nexport function normalizeUrl(val: string): string {\n const trimmed = val.trim();\n if (/^https?:\\/\\//i.test(trimmed)) return trimmed;\n return `https://${trimmed}`;\n}\n\n/**\n * Accept a URL string or silently drop it if invalid (returns `undefined`).\n * Preserves the write-time policy: bad URLs from imports are dropped, not rejected.\n */\nexport const optionalUrl = () =>\n z\n .string()\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n try {\n new URL(val);\n return val;\n } catch {\n return undefined;\n }\n });\n\n/**\n * Location shape accepted by the sifa-api write endpoints.\n *\n * Accepts BOTH the legacy shape (`id.sifa.defs#locationAddress`: `countryCode`,\n * `region`, `city`) AND the new community shape\n * (`community.lexicon.location.address`: `country`, `region`, `locality`,\n * `street?`, `postalCode?`, `name?`). The frontend reads location records from\n * the API and echoes them back on save. The API serializer emits explicit `null`\n * for absent fields (not `undefined`), so every field uses `.nullish()`\n * (`string | null | undefined`) instead of `.optional()` (`string | undefined`).\n *\n * `buildPdsLocation` on the server handles conversion to the PDS shape (always\n * emitting the new community shape) and returns `undefined` when neither\n * `country` nor `countryCode` is usable.\n */\nexport const writeLocationSchema = z\n .union([\n z.object({\n country: z.string().nullish(),\n countryCode: z.string().length(2).nullish(),\n region: z.string().nullish(),\n city: z.string().nullish(),\n locality: z.string().nullish(),\n street: z.string().nullish(),\n postalCode: z.string().nullish(),\n name: z.string().nullish(),\n }),\n z.string(),\n ])\n .nullable()\n .optional();\n\n/** Skill reference: a strong ref to a canonical skill record. */\nexport const skillRefSchema = z.object({\n uri: z.string(),\n});\n\n/**\n * Platforms accepted by the external-account write endpoint.\n *\n * NOTE: this list intentionally differs from `PLATFORM_LABELS` in the SDK's\n * `/taxonomy` subpath. `VALID_PLATFORMS` is what sifa-api's `POST /external-accounts`\n * endpoint enforces; `PLATFORM_LABELS` is the display taxonomy used by the profile\n * UI. Reconciling them is a separate follow-up (see #TBD). For now the two are\n * mirrored verbatim from their prior definitions to preserve behavior.\n */\nexport const VALID_PLATFORMS = [\n 'rss',\n 'fediverse',\n 'twitter',\n 'instagram',\n 'github',\n 'codeberg',\n 'gitlab',\n 'forgejo',\n 'gitea',\n 'youtube',\n 'linkedin',\n 'substack',\n 'website',\n 'orcid',\n 'keyoxide',\n 'other',\n] as const;\n\nexport type ValidPlatform = (typeof VALID_PLATFORMS)[number];\n","import { z } from 'zod';\n\nimport { optionalUrl } from './shared.js';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.certification`. */\nexport const CertificationWriteSchema = z.object({\n name: z.string().min(1).max(256),\n authority: z.string().max(256).nullable().optional(),\n credentialId: z.string().max(256).nullable().optional(),\n credentialUrl: optionalUrl(),\n issuedAt: z.string().nullable().optional(),\n expiresAt: z.string().nullable().optional(),\n});\n\nexport type CertificationWriteInput = z.infer<typeof CertificationWriteSchema>;\n","import { z } from 'zod';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.course`. */\nexport const CourseWriteSchema = z.object({\n name: z.string().min(1).max(200),\n number: z.string().max(50).nullable().optional(),\n institution: z.string().max(256).nullable().optional(),\n});\n\nexport type CourseWriteInput = z.infer<typeof CourseWriteSchema>;\n","import { z } from 'zod';\n\n/** Schema enforced by `POST /profile/education` on sifa-api. */\nexport const EducationWriteSchema = z.object({\n institution: z.string().min(1).max(256),\n degree: z.string().max(256).nullable().optional(),\n fieldOfStudy: z.string().max(256).nullable().optional(),\n description: z.string().max(50000).nullable().optional(),\n activities: z.string().max(1000).nullable().optional(),\n startedAt: z.string().nullable().optional(),\n endedAt: z.string().nullable().optional(),\n});\n\nexport type EducationWriteInput = z.infer<typeof EducationWriteSchema>;\n","import { z } from 'zod';\n\nimport { VALID_PLATFORMS, normalizeUrl } from './shared.js';\n\n/** Schema enforced by `POST /external-accounts` on sifa-api. */\nexport const ExternalAccountWriteSchema = z.object({\n platform: z.enum(VALID_PLATFORMS),\n url: z.string().max(2000).transform(normalizeUrl).pipe(z.string().url()),\n label: z.string().max(100).optional(),\n feedUrl: z.string().max(2000).transform(normalizeUrl).pipe(z.string().url()).optional(),\n});\n\nexport type ExternalAccountWriteInput = z.infer<typeof ExternalAccountWriteSchema>;\n","import { z } from 'zod';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.honor`. */\nexport const HonorWriteSchema = z.object({\n title: z.string().min(1).max(200),\n issuer: z.string().max(256).nullable().optional(),\n description: z.string().max(50000).nullable().optional(),\n awardedAt: z.string().nullable().optional(),\n});\n\nexport type HonorWriteInput = z.infer<typeof HonorWriteSchema>;\n","import { z } from 'zod';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.language`. */\nexport const LanguageWriteSchema = z.object({\n name: z.string().min(1).max(64),\n proficiency: z.string().max(50).optional(),\n});\n\nexport type LanguageWriteInput = z.infer<typeof LanguageWriteSchema>;\n","import { z } from 'zod';\n\nimport { skillRefSchema, writeLocationSchema } from './shared.js';\n\n/**\n * Schema enforced by `POST /profile/positions` on sifa-api.\n *\n * Client-side callers can `.safeParse(...)` this before submitting to catch\n * obvious problems (empty `title`, over-length text) before the network\n * round-trip. If it passes here, the API will accept the write modulo\n * transport / auth failures.\n *\n * `company` is intentionally optional to support freelancer / independent\n * employment types where the position has no employer. The current\n * `sifa-api/src/routes/schemas.ts` requires `company` (`.min(1)`); the\n * sifa-api adoption PR that consumes this schema will therefore be a\n * behavior change that unblocks the freelancer flow. The SDK's lexicon\n * schema (`ProfilePositionRecordSchema`) has treated `company` as optional\n * since sifa-sdk #184.\n */\nexport const PositionWriteSchema = z.object({\n company: z.string().min(1).max(256).nullable().optional(),\n title: z.string().min(1).max(256),\n description: z.string().max(50000).nullable().optional(),\n employmentType: z.string().nullable().optional(),\n workplaceType: z.string().nullable().optional(),\n location: writeLocationSchema,\n startedAt: z.string().nullable().optional(),\n endedAt: z.string().nullable().optional(),\n skills: z.array(skillRefSchema).max(50).nullable().optional(),\n});\n\nexport type PositionWriteInput = z.infer<typeof PositionWriteSchema>;\n","import { z } from 'zod';\n\n/**\n * Schema enforced by `POST /profile/locations` on sifa-api.\n *\n * Mirrors the inner object of `writeLocationSchema`: accepts both the community\n * shape (`country`, `locality`) and the legacy shape (`countryCode`, `city`)\n * during the dual-read window. sifa-web #840 switched outbound writes to the\n * community shape; older clients may still send the legacy shape. All address\n * fields are `.nullish()` so explicit `null` from API echoes is accepted\n * (see sifa-api #426).\n *\n * The route handler hands `address` to `buildPdsLocation`, which normalizes\n * either input and enforces alpha-2 on the wire to PDS — returning a 400 with\n * `message: \"address.country (alpha-2) is required\"` when no usable code is\n * present. The schema stays permissive on country length here and lets\n * `buildPdsLocation` be the single enforcement point.\n */\nexport const ProfileLocationWriteSchema = z.object({\n address: z.object({\n country: z.string().nullish(),\n countryCode: z.string().length(2).nullish(),\n region: z.string().nullish(),\n city: z.string().nullish(),\n locality: z.string().nullish(),\n street: z.string().nullish(),\n postalCode: z.string().nullish(),\n name: z.string().nullish(),\n }),\n type: z.string().min(1),\n label: z.string().max(60).nullable().optional(),\n isPrimary: z.boolean().optional(),\n});\n\nexport type ProfileLocationWriteInput = z.infer<typeof ProfileLocationWriteSchema>;\n","import { z } from 'zod';\n\nimport { writeLocationSchema } from './shared.js';\n\n/**\n * Schema enforced by `POST /profile/self` on sifa-api.\n *\n * `.passthrough()` so the API accepts fields not yet enumerated here (used for\n * gradual rollout of new profile-self keys without requiring lockstep bumps\n * between web/api). Note this means client validation on this schema will\n * NEVER reject \"unknown\" fields — the divergence is intentional.\n *\n * Grapheme caps (e.g. 64 on given/familyName) are enforced client-side by the\n * SDK's lexicon schema; the write schema only guards the byte-length ceiling.\n */\nexport const ProfileSelfWriteSchema = z\n .object({\n headline: z.string().max(300).optional(),\n about: z.string().max(50000).optional(),\n givenName: z.string().max(640).optional(),\n familyName: z.string().max(640).optional(),\n industries: z\n .array(\n z.object({\n industry: z.string().max(100),\n domain: z.string().max(100).optional(),\n }),\n )\n .max(10)\n .optional(),\n location: writeLocationSchema,\n openTo: z.array(z.string()).max(10).optional(),\n preferredWorkplace: z.array(z.string()).max(5).optional(),\n availableFromUtc: z.number().int().min(0).max(23).optional(),\n availableToUtc: z.number().int().min(0).max(23).optional(),\n langs: z.array(z.string()).max(3).optional(),\n discoverable: z.boolean().optional(),\n })\n .passthrough();\n\nexport type ProfileSelfWriteInput = z.infer<typeof ProfileSelfWriteSchema>;\n","import { z } from 'zod';\n\nimport { optionalUrl } from './shared.js';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.project`. */\nexport const ProjectWriteSchema = z.object({\n name: z.string().min(1).max(256),\n description: z.string().max(50000).nullable().optional(),\n url: optionalUrl(),\n startedAt: z.string().nullable().optional(),\n endedAt: z.string().nullable().optional(),\n});\n\nexport type ProjectWriteInput = z.infer<typeof ProjectWriteSchema>;\n","import { z } from 'zod';\n\nimport { optionalUrl } from './shared.js';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.publication`. */\nexport const PublicationWriteSchema = z.object({\n title: z.string().min(1).max(200),\n publisher: z.string().max(256).nullable().optional(),\n url: optionalUrl(),\n description: z.string().max(50000).nullable().optional(),\n publishedAt: z.string().nullable().optional(),\n});\n\nexport type PublicationWriteInput = z.infer<typeof PublicationWriteSchema>;\n","import { z } from 'zod';\n\n/** Schema enforced by `POST /profile/skills` on sifa-api. */\nexport const SkillWriteSchema = z.object({\n name: z.string().min(1).max(100),\n category: z.string().max(100).optional(),\n});\n\nexport type SkillWriteInput = z.infer<typeof SkillWriteSchema>;\n","import { z } from 'zod';\n\n/** Schema enforced by the generic-record write endpoint for `id.sifa.profile.volunteering`. */\nexport const VolunteeringWriteSchema = z.object({\n organization: z.string().min(1).max(256),\n role: z.string().max(256).nullable().optional(),\n cause: z.string().max(256).nullable().optional(),\n description: z.string().max(50000).nullable().optional(),\n startedAt: z.string().nullable().optional(),\n endedAt: z.string().nullable().optional(),\n});\n\nexport type VolunteeringWriteInput = z.infer<typeof VolunteeringWriteSchema>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singi-labs/sifa-sdk",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Sifa SDK — public client library for the Sifa AppView on AT Protocol. Shared by sifa-web and sifa-app.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,6 +52,16 @@
52
52
  "default": "./dist/schemas/index.cjs"
53
53
  }
54
54
  },
55
+ "./schemas/write": {
56
+ "import": {
57
+ "types": "./dist/schemas/write/index.d.ts",
58
+ "default": "./dist/schemas/write/index.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/schemas/write/index.d.cts",
62
+ "default": "./dist/schemas/write/index.cjs"
63
+ }
64
+ },
55
65
  "./query": {
56
66
  "import": {
57
67
  "types": "./dist/query/index.d.ts",