@xnetjs/data 0.0.2 → 0.1.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.
Files changed (139) hide show
  1. package/README.md +112 -0
  2. package/dist/account-MWNCH4GJ.js +12 -0
  3. package/dist/account-ledger-R2GAFJL6.js +38 -0
  4. package/dist/auth/index.d.ts +420 -0
  5. package/dist/auth/index.js +102 -0
  6. package/dist/budget-NN7P35XP.js +12 -0
  7. package/dist/canvas-6WYBNH53.js +10 -0
  8. package/dist/channel-AT3LQF4A.js +12 -0
  9. package/dist/chat-message-DSVO72B3.js +10 -0
  10. package/dist/chunk-2ZNJWIQG.js +84 -0
  11. package/dist/chunk-3J3HILXO.js +46 -0
  12. package/dist/chunk-3RUDVTMH.js +5543 -0
  13. package/dist/chunk-4EYKGTSQ.js +49 -0
  14. package/dist/chunk-53F4PRNC.js +32 -0
  15. package/dist/chunk-5EXHNXPL.js +48 -0
  16. package/dist/{chunk-BQBPA5HS.js → chunk-5HC5NO57.js} +16 -2
  17. package/dist/chunk-6KLGA6IR.js +47 -0
  18. package/dist/chunk-6OMG4I7M.js +41 -0
  19. package/dist/chunk-7PDRDSFH.js +69 -0
  20. package/dist/chunk-BQLQSWKZ.js +232 -0
  21. package/dist/chunk-BY5O6LNC.js +380 -0
  22. package/dist/chunk-DCTRX6II.js +40 -0
  23. package/dist/{chunk-VYR5GPJP.js → chunk-DWEXKD6E.js} +9 -3
  24. package/dist/chunk-EBNMV2VO.js +896 -0
  25. package/dist/chunk-FVEACSKE.js +102 -0
  26. package/dist/chunk-GU6THOAB.js +45 -0
  27. package/dist/chunk-H4GA4BBK.js +75 -0
  28. package/dist/chunk-IJ44LR7N.js +76 -0
  29. package/dist/chunk-J4ANIXIV.js +402 -0
  30. package/dist/chunk-JDFNMFOZ.js +45 -0
  31. package/dist/chunk-K7DOZWWT.js +1811 -0
  32. package/dist/chunk-KQAT4XBL.js +49 -0
  33. package/dist/chunk-KQUALW4O.js +183 -0
  34. package/dist/chunk-LYSWLCOI.js +47 -0
  35. package/dist/chunk-MBTUO3ZL.js +65 -0
  36. package/dist/chunk-NI4FHG2K.js +52 -0
  37. package/dist/chunk-OCMSAKWV.js +78 -0
  38. package/dist/chunk-OGJCRNGE.js +57 -0
  39. package/dist/chunk-OPPHF3TF.js +143 -0
  40. package/dist/{chunk-IDMBCRUC.js → chunk-OSAWNZVM.js} +1 -1
  41. package/dist/chunk-PMUQACPY.js +33 -0
  42. package/dist/chunk-PNESGUH5.js +63 -0
  43. package/dist/chunk-Q3IEGH4B.js +51 -0
  44. package/dist/chunk-QJW5LDP4.js +52 -0
  45. package/dist/chunk-QWFTRZQT.js +142 -0
  46. package/dist/{chunk-SZC345Z2.js → chunk-RL64OJJ5.js} +1025 -1110
  47. package/dist/chunk-S5RP5RKY.js +416 -0
  48. package/dist/chunk-S6U6TCMN.js +722 -0
  49. package/dist/chunk-SVNGSZZA.js +69 -0
  50. package/dist/chunk-T5AZAOG5.js +54 -0
  51. package/dist/chunk-TCTZW4A6.js +42 -0
  52. package/dist/chunk-U64CW73O.js +109 -0
  53. package/dist/chunk-UDWKWTAX.js +6526 -0
  54. package/dist/chunk-UQM3G5A2.js +148 -0
  55. package/dist/chunk-VQ7JHB67.js +57 -0
  56. package/dist/chunk-W7EBL7ZU.js +73 -0
  57. package/dist/chunk-WEPK7SZF.js +65 -0
  58. package/dist/chunk-XHEA5UER.js +75 -0
  59. package/dist/chunk-XMSKJ5PV.js +66 -0
  60. package/dist/chunk-XROI44ZP.js +64 -0
  61. package/dist/chunk-Y3S5SRVM.js +45 -0
  62. package/dist/chunk-YEFKQYKA.js +43 -0
  63. package/dist/chunk-YSUIXD2Y.js +105 -0
  64. package/dist/chunk-ZCOFZY5M.js +70 -0
  65. package/dist/chunk-ZLU4Y3O2.js +50 -0
  66. package/dist/chunk-ZPZ7XDA6.js +54 -0
  67. package/dist/chunk-ZZ6TWKGS.js +40 -0
  68. package/dist/clone-C0Jhk2UN.d.ts +2205 -0
  69. package/dist/comment-QSWYAQVS.js +10 -0
  70. package/dist/crm-L5RYAAF3.js +68 -0
  71. package/dist/dashboard-JMKTTRA7.js +10 -0
  72. package/dist/database/index.d.ts +882 -0
  73. package/dist/database/index.js +523 -0
  74. package/dist/database-GIXSPZJW.js +10 -0
  75. package/dist/database-field-3EPAMZUR.js +10 -0
  76. package/dist/database-row-6Q6TRVE4.js +10 -0
  77. package/dist/database-select-option-BBBJFLLH.js +10 -0
  78. package/dist/database-view-5PLSOBI2.js +10 -0
  79. package/dist/experiment-DOVOZ34Y.js +10 -0
  80. package/dist/external-item-P2E5X7BZ.js +14 -0
  81. package/dist/external-reference-7BSFF6SA.js +8 -0
  82. package/dist/feed-2IXHHP6O.js +12 -0
  83. package/dist/feed-item-DPE6LN7I.js +12 -0
  84. package/dist/folder-6KM3KYD5.js +21 -0
  85. package/dist/game-5AK5XWBR.js +50 -0
  86. package/dist/grant-WTQSNT5A.js +8 -0
  87. package/dist/grant-expiration-cleaner-CY6BcmlR.d.ts +249 -0
  88. package/dist/import-batch-IXBJLQPJ.js +12 -0
  89. package/dist/inbox-state-E5NSVOGP.js +12 -0
  90. package/dist/index.d.ts +224 -4548
  91. package/dist/index.js +2252 -4754
  92. package/dist/map-RG5Y3CPC.js +10 -0
  93. package/dist/media-asset-QTCGLIZA.js +8 -0
  94. package/dist/memory-PNRTMBZO.js +12 -0
  95. package/dist/metric-65SVOX5C.js +10 -0
  96. package/dist/milestone-XEO6ZGDG.js +12 -0
  97. package/dist/moderation-FFHETMRB.js +30 -0
  98. package/dist/observation-2Y3QKUXM.js +10 -0
  99. package/dist/page-2V27JGKJ.js +10 -0
  100. package/dist/posting-GBOSZCMZ.js +12 -0
  101. package/dist/profile-BLLDWIDK.js +8 -0
  102. package/dist/project-CQL5LN26.js +10 -0
  103. package/dist/query-ast-C3m6kZYv.d.ts +226 -0
  104. package/dist/reaction-T2DTJBBV.js +10 -0
  105. package/dist/registry-DunPv__d.d.ts +99 -0
  106. package/dist/saved-view-4R2DBCL3.js +10 -0
  107. package/dist/schema/index.d.ts +6489 -0
  108. package/dist/schema/index.js +677 -0
  109. package/dist/schema-extension-LNRF2YRD.js +18 -0
  110. package/dist/space-IJU24PBH.js +42 -0
  111. package/dist/space-membership-DEUMM7NV.js +14 -0
  112. package/dist/store/index.d.ts +518 -0
  113. package/dist/store/index.js +135 -0
  114. package/dist/store-DtIDjk7c.d.ts +355 -0
  115. package/dist/sync/awareness.d.ts +69 -0
  116. package/dist/sync/awareness.js +20 -0
  117. package/dist/system-ILHCZOVO.js +38 -0
  118. package/dist/tag-SKCHM3U5.js +16 -0
  119. package/dist/task-7AOBP7WC.js +16 -0
  120. package/dist/task-view-NUGKELJP.js +10 -0
  121. package/dist/transaction-ZDSEGDIR.js +12 -0
  122. package/dist/transcription-PSCLDAGX.js +12 -0
  123. package/dist/types-S-BJAKyK.d.ts +1576 -0
  124. package/dist/updates.d.ts +44 -0
  125. package/dist/updates.js +16 -0
  126. package/dist/user-widget-RLY2N46A.js +8 -0
  127. package/dist/view-types-DSde-uT_.d.ts +316 -0
  128. package/package.json +32 -9
  129. package/dist/canvas-HSIKIQFK.js +0 -7
  130. package/dist/chunk-2L5ZUGG5.js +0 -53
  131. package/dist/chunk-4MTS5KAQ.js +0 -22
  132. package/dist/chunk-GZHARFKC.js +0 -25
  133. package/dist/chunk-WKIKJTI2.js +0 -45
  134. package/dist/comment-277JD7DV.js +0 -7
  135. package/dist/database-W3KEHLI3.js +0 -7
  136. package/dist/database-row-3O2QSNZN.js +0 -7
  137. package/dist/grant-QVZ454YC.js +0 -7
  138. package/dist/page-O4WTOIEO.js +0 -7
  139. package/dist/task-SEKAYJH7.js +0 -7
@@ -0,0 +1,402 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ checkbox,
6
+ date,
7
+ defineSchema,
8
+ email,
9
+ number,
10
+ person,
11
+ phone,
12
+ relation,
13
+ select,
14
+ text,
15
+ url
16
+ } from "./chunk-EBNMV2VO.js";
17
+
18
+ // src/schema/schemas/crm.ts
19
+ var CRM_NAMESPACE = "xnet://xnet.fyi/";
20
+ var ORGANIZATION_SCHEMA_IRI = "xnet://xnet.fyi/Organization@1.0.0";
21
+ var CONTACT_SCHEMA_IRI = "xnet://xnet.fyi/Contact@1.0.0";
22
+ var RELATIONSHIP_SCHEMA_IRI = "xnet://xnet.fyi/Relationship@1.0.0";
23
+ var PIPELINE_SCHEMA_IRI = "xnet://xnet.fyi/Pipeline@1.0.0";
24
+ var STAGE_SCHEMA_IRI = "xnet://xnet.fyi/Stage@1.0.0";
25
+ var DEAL_SCHEMA_IRI = "xnet://xnet.fyi/Deal@1.0.0";
26
+ var DEAL_CONTACT_ROLE_SCHEMA_IRI = "xnet://xnet.fyi/DealContactRole@1.0.0";
27
+ var ACTIVITY_SCHEMA_IRI = "xnet://xnet.fyi/Activity@1.0.0";
28
+ var PRODUCT_SCHEMA_IRI = "xnet://xnet.fyi/Product@1.0.0";
29
+ var LINE_ITEM_SCHEMA_IRI = "xnet://xnet.fyi/LineItem@1.0.0";
30
+ var SPACE_TARGET = "xnet://xnet.fyi/Space@1.0.0";
31
+ var TAG_TARGET = "xnet://xnet.fyi/Tag@1.0.0";
32
+ var FOLDER_TARGET = "xnet://xnet.fyi/Folder@1.0.0";
33
+ var TRANSACTION_TARGET = "xnet://xnet.fyi/Transaction@1.0.0";
34
+ var SOCIAL_ACTOR_TARGET = "xnet://xnet.social/SocialActor@1.0.0";
35
+ var VISIBILITY_OPTIONS = [
36
+ { id: "inherit", name: "Inherit", color: "gray" },
37
+ { id: "private", name: "Private", color: "gray" },
38
+ { id: "unlisted", name: "Unlisted", color: "yellow" },
39
+ { id: "public", name: "Public", color: "green" }
40
+ ];
41
+ var visibility = () => select({ options: VISIBILITY_OPTIONS, default: "inherit" });
42
+ var space = () => relation({ target: SPACE_TARGET });
43
+ var folder = () => relation({ target: FOLDER_TARGET });
44
+ var ORGANIZATION_SIZES = [
45
+ { id: "solo", name: "1" },
46
+ { id: "small", name: "2\u201310" },
47
+ { id: "medium", name: "11\u201350" },
48
+ { id: "large", name: "51\u2013250" },
49
+ { id: "xlarge", name: "251\u20131000" },
50
+ { id: "enterprise", name: "1000+" }
51
+ ];
52
+ var OrganizationSchema = defineSchema({
53
+ name: "Organization",
54
+ namespace: CRM_NAMESPACE,
55
+ properties: {
56
+ /** Company / account name. */
57
+ name: text({ required: true, maxLength: 300 }),
58
+ /** Primary email domain (the natural dedup key for B2B). */
59
+ domain: text({ maxLength: 255 }),
60
+ website: url({}),
61
+ industry: text({ maxLength: 120 }),
62
+ size: select({ options: ORGANIZATION_SIZES }),
63
+ /** Annual revenue, in `currency`. */
64
+ annualRevenue: number({ min: 0 }),
65
+ currency: text({ maxLength: 3 }),
66
+ phone: phone({}),
67
+ street: text({ maxLength: 300 }),
68
+ city: text({ maxLength: 120 }),
69
+ region: text({ maxLength: 120 }),
70
+ postalCode: text({ maxLength: 40 }),
71
+ country: text({ maxLength: 120 }),
72
+ /** Parent company — self-reference for account hierarchies. */
73
+ parent: relation({ target: ORGANIZATION_SCHEMA_IRI }),
74
+ /** Account owner (the rep). */
75
+ owner: person({}),
76
+ /** Optional link to an imported `@xnetjs/social` actor (org kind). */
77
+ actor: relation({ target: SOCIAL_ACTOR_TARGET }),
78
+ tags: relation({ target: TAG_TARGET, multiple: true }),
79
+ /** Erasure-by-design: set when PII is anonymized (GDPR Art. 17). */
80
+ piiErasedAt: date({}),
81
+ folder: folder(),
82
+ space: space(),
83
+ visibility: visibility()
84
+ },
85
+ document: "yjs",
86
+ // Collaborative account notes
87
+ authorization: spaceCascadeAuthorization()
88
+ });
89
+ var CONTACT_LIFECYCLE = [
90
+ { id: "subscriber", name: "Subscriber", color: "gray" },
91
+ { id: "lead", name: "Lead", color: "yellow" },
92
+ { id: "mql", name: "Marketing Qualified", color: "blue" },
93
+ { id: "sql", name: "Sales Qualified", color: "purple" },
94
+ { id: "opportunity", name: "Opportunity", color: "orange" },
95
+ { id: "customer", name: "Customer", color: "green" },
96
+ { id: "evangelist", name: "Evangelist", color: "green" },
97
+ { id: "churned", name: "Churned", color: "red" }
98
+ ];
99
+ var ContactSchema = defineSchema({
100
+ name: "Contact",
101
+ namespace: CRM_NAMESPACE,
102
+ properties: {
103
+ /** Display name — the one always-required field. */
104
+ displayName: text({ required: true, maxLength: 200 }),
105
+ firstName: text({ maxLength: 100 }),
106
+ lastName: text({ maxLength: 100 }),
107
+ /** Primary email (the natural dedup key for people). */
108
+ email: email({}),
109
+ /** Primary phone. */
110
+ phone: phone({}),
111
+ title: text({ maxLength: 200 }),
112
+ /** Employer / account. */
113
+ org: relation({ target: ORGANIZATION_SCHEMA_IRI }),
114
+ /** The rep who owns this relationship. */
115
+ owner: person({}),
116
+ /**
117
+ * OPTIONAL: the contact's *own* xNet identity (a DID). When set, the
118
+ * contact can control their own half of the record — the user-owned,
119
+ * bilateral-consent differentiator (exploration 0188).
120
+ */
121
+ did: person({}),
122
+ /** Optional link to a `@xnetjs/social` actor for import/dedup. */
123
+ actor: relation({ target: SOCIAL_ACTOR_TARGET }),
124
+ lifecycle: select({ options: CONTACT_LIFECYCLE, default: "lead" }),
125
+ /** When this contact was last interacted with (drives keep-in-touch). */
126
+ lastTouchAt: date({}),
127
+ /** Next time to reach out — derived from `lastTouchAt` + `touchEveryDays`. */
128
+ nextTouchAt: date({}),
129
+ /** Keep-in-touch cadence, in days (0/empty = no cadence). */
130
+ touchEveryDays: number({ integer: true, min: 0 }),
131
+ /** Personal-CRM context: how the relationship started. */
132
+ howWeMet: text({ maxLength: 2e3 }),
133
+ /** The contact who introduced you (the introducer edge). */
134
+ introducedBy: relation({ target: CONTACT_SCHEMA_IRI }),
135
+ tags: relation({ target: TAG_TARGET, multiple: true }),
136
+ piiErasedAt: date({}),
137
+ folder: folder(),
138
+ space: space(),
139
+ visibility: visibility()
140
+ },
141
+ document: "yjs",
142
+ // Running notes / journal on the person
143
+ authorization: spaceCascadeAuthorization()
144
+ });
145
+ var RELATIONSHIP_KINDS = [
146
+ { id: "spouse", name: "Spouse" },
147
+ { id: "partner", name: "Partner" },
148
+ { id: "parent", name: "Parent" },
149
+ { id: "child", name: "Child" },
150
+ { id: "sibling", name: "Sibling" },
151
+ { id: "friend", name: "Friend" },
152
+ { id: "colleague", name: "Colleague" },
153
+ { id: "manager", name: "Manager" },
154
+ { id: "reports-to", name: "Reports to" },
155
+ { id: "introduced-by", name: "Introduced by" },
156
+ { id: "knows", name: "Knows" }
157
+ ];
158
+ var RelationshipSchema = defineSchema({
159
+ name: "Relationship",
160
+ namespace: CRM_NAMESPACE,
161
+ properties: {
162
+ from: relation({ target: CONTACT_SCHEMA_IRI, required: true }),
163
+ to: relation({ target: CONTACT_SCHEMA_IRI, required: true }),
164
+ kind: select({ options: RELATIONSHIP_KINDS, default: "knows" }),
165
+ note: text({ maxLength: 1e3 }),
166
+ space: space(),
167
+ visibility: visibility()
168
+ },
169
+ authorization: spaceCascadeAuthorization()
170
+ });
171
+ var PipelineSchema = defineSchema({
172
+ name: "Pipeline",
173
+ namespace: CRM_NAMESPACE,
174
+ properties: {
175
+ name: text({ required: true, maxLength: 200 }),
176
+ description: text({ maxLength: 1e3 }),
177
+ sortKey: text({ maxLength: 500 }),
178
+ /** Exactly one pipeline should be the default for new deals. */
179
+ isDefault: checkbox({ default: false }),
180
+ space: space(),
181
+ visibility: visibility()
182
+ },
183
+ authorization: spaceCascadeAuthorization()
184
+ });
185
+ var StageSchema = defineSchema({
186
+ name: "Stage",
187
+ namespace: CRM_NAMESPACE,
188
+ properties: {
189
+ name: text({ required: true, maxLength: 120 }),
190
+ pipeline: relation({ target: PIPELINE_SCHEMA_IRI, required: true }),
191
+ /** Column order within the pipeline. */
192
+ sortKey: text({ maxLength: 500 }),
193
+ /** Default win probability for deals in this stage, 0–1. */
194
+ probability: number({ min: 0, max: 1 }),
195
+ /** Terminal flags — `isClosed` + `isWon` is the standard termination pair. */
196
+ isClosed: checkbox({ default: false }),
197
+ isWon: checkbox({ default: false }),
198
+ color: text({ maxLength: 32 }),
199
+ space: space(),
200
+ visibility: visibility()
201
+ },
202
+ authorization: spaceCascadeAuthorization()
203
+ });
204
+ var FORECAST_CATEGORIES = [
205
+ { id: "pipeline", name: "Pipeline", color: "gray" },
206
+ { id: "best-case", name: "Best Case", color: "blue" },
207
+ { id: "commit", name: "Commit", color: "green" },
208
+ { id: "closed", name: "Closed", color: "purple" }
209
+ ];
210
+ var DEAL_SOURCES = [
211
+ { id: "inbound", name: "Inbound" },
212
+ { id: "outbound", name: "Outbound" },
213
+ { id: "referral", name: "Referral" },
214
+ { id: "partner", name: "Partner" },
215
+ { id: "event", name: "Event" },
216
+ { id: "other", name: "Other" }
217
+ ];
218
+ var DealSchema = defineSchema({
219
+ name: "Deal",
220
+ namespace: CRM_NAMESPACE,
221
+ properties: {
222
+ title: text({ required: true, maxLength: 300 }),
223
+ /** Account (company) the deal is with. */
224
+ org: relation({ target: ORGANIZATION_SCHEMA_IRI }),
225
+ /** Primary contact (full stakeholder set lives in DealContactRole). */
226
+ primaryContact: relation({ target: CONTACT_SCHEMA_IRI }),
227
+ pipeline: relation({ target: PIPELINE_SCHEMA_IRI }),
228
+ stage: relation({ target: STAGE_SCHEMA_IRI }),
229
+ amount: number({ min: 0 }),
230
+ currency: text({ maxLength: 3 }),
231
+ /** Optional override of the stage's default probability, 0–1. */
232
+ probability: number({ min: 0, max: 1 }),
233
+ closeDate: date({}),
234
+ forecastCategory: select({ options: FORECAST_CATEGORIES, default: "pipeline" }),
235
+ source: select({ options: DEAL_SOURCES }),
236
+ owner: person({}),
237
+ collaborators: person({ multiple: true }),
238
+ wonAt: date({}),
239
+ lostAt: date({}),
240
+ lostReason: text({ maxLength: 500 }),
241
+ /**
242
+ * Ledger transactions that realize this deal's revenue (quote-to-cash
243
+ * bridge, exploration 0190). A won deal can link the booked income so
244
+ * pipeline and books reconcile.
245
+ */
246
+ transactions: relation({ target: TRANSACTION_TARGET, multiple: true }),
247
+ tags: relation({ target: TAG_TARGET, multiple: true }),
248
+ folder: folder(),
249
+ space: space(),
250
+ visibility: visibility()
251
+ },
252
+ document: "yjs",
253
+ // Deal notes
254
+ authorization: spaceCascadeAuthorization()
255
+ });
256
+ var DEAL_CONTACT_ROLES = [
257
+ { id: "decision-maker", name: "Decision Maker" },
258
+ { id: "economic-buyer", name: "Economic Buyer" },
259
+ { id: "champion", name: "Champion" },
260
+ { id: "influencer", name: "Influencer" },
261
+ { id: "technical-buyer", name: "Technical Buyer" },
262
+ { id: "user", name: "User" },
263
+ { id: "evaluator", name: "Evaluator" },
264
+ { id: "other", name: "Other" }
265
+ ];
266
+ var DealContactRoleSchema = defineSchema({
267
+ name: "DealContactRole",
268
+ namespace: CRM_NAMESPACE,
269
+ properties: {
270
+ deal: relation({ target: DEAL_SCHEMA_IRI, required: true }),
271
+ contact: relation({ target: CONTACT_SCHEMA_IRI, required: true }),
272
+ role: select({ options: DEAL_CONTACT_ROLES, default: "other" }),
273
+ isPrimary: checkbox({ default: false }),
274
+ space: space(),
275
+ visibility: visibility()
276
+ },
277
+ authorization: spaceCascadeAuthorization()
278
+ });
279
+ var ACTIVITY_KINDS = [
280
+ { id: "note", name: "Note" },
281
+ { id: "call", name: "Call" },
282
+ { id: "email", name: "Email" },
283
+ { id: "meeting", name: "Meeting" },
284
+ { id: "task", name: "Task" }
285
+ ];
286
+ var ActivitySchema = defineSchema({
287
+ name: "Activity",
288
+ namespace: CRM_NAMESPACE,
289
+ properties: {
290
+ kind: select({ options: ACTIVITY_KINDS, default: "note" }),
291
+ /** The *who* — Salesforce `WhoId`. */
292
+ contact: relation({ target: CONTACT_SCHEMA_IRI }),
293
+ /** The *what* — Salesforce `WhatId`. Untyped relation so it can point at a
294
+ * Deal, Organization, or Contact (polymorphic). */
295
+ about: relation({}),
296
+ /** One-line summary shown in the timeline. */
297
+ summary: text({ maxLength: 500 }),
298
+ /** Full body — kept separate from the contact FK so erasure can null PII
299
+ * while preserving the activity's existence for audit/aggregates. */
300
+ body: text({ maxLength: 2e4 }),
301
+ direction: select({
302
+ options: [
303
+ { id: "inbound", name: "Inbound" },
304
+ { id: "outbound", name: "Outbound" }
305
+ ]
306
+ }),
307
+ occurredAt: date({ includeTime: true }),
308
+ durationSec: number({ integer: true, min: 0 }),
309
+ outcome: text({ maxLength: 300 }),
310
+ /** For task-kind activities: future due date + completion. */
311
+ dueAt: date({}),
312
+ completed: checkbox({ default: false }),
313
+ owner: person({}),
314
+ space: space(),
315
+ visibility: visibility()
316
+ },
317
+ authorization: spaceCascadeAuthorization()
318
+ });
319
+ var PRODUCT_KINDS = [
320
+ { id: "good", name: "Good" },
321
+ { id: "service", name: "Service" },
322
+ { id: "subscription", name: "Subscription" }
323
+ ];
324
+ var ProductSchema = defineSchema({
325
+ name: "Product",
326
+ namespace: CRM_NAMESPACE,
327
+ properties: {
328
+ name: text({ required: true, maxLength: 300 }),
329
+ /** Stock-keeping unit / product code. */
330
+ sku: text({ maxLength: 120 }),
331
+ description: text({ maxLength: 2e3 }),
332
+ kind: select({ options: PRODUCT_KINDS, default: "service" }),
333
+ unitPrice: number({ min: 0 }),
334
+ currency: text({ maxLength: 3 }),
335
+ active: checkbox({ default: true }),
336
+ space: space(),
337
+ visibility: visibility()
338
+ },
339
+ authorization: spaceCascadeAuthorization()
340
+ });
341
+ var LineItemSchema = defineSchema({
342
+ name: "LineItem",
343
+ namespace: CRM_NAMESPACE,
344
+ properties: {
345
+ deal: relation({ target: DEAL_SCHEMA_IRI, required: true }),
346
+ product: relation({ target: PRODUCT_SCHEMA_IRI }),
347
+ description: text({ maxLength: 500 }),
348
+ quantity: number({ min: 0 }),
349
+ /** Overrides the product's `unitPrice` when set. */
350
+ unitPrice: number({ min: 0 }),
351
+ /** Discount fraction, 0–1. */
352
+ discount: number({ min: 0, max: 1 }),
353
+ space: space(),
354
+ visibility: visibility()
355
+ },
356
+ authorization: spaceCascadeAuthorization()
357
+ });
358
+ var crmSchemas = [
359
+ OrganizationSchema,
360
+ ContactSchema,
361
+ RelationshipSchema,
362
+ PipelineSchema,
363
+ StageSchema,
364
+ DealSchema,
365
+ DealContactRoleSchema,
366
+ ActivitySchema,
367
+ ProductSchema,
368
+ LineItemSchema
369
+ ];
370
+
371
+ export {
372
+ CRM_NAMESPACE,
373
+ ORGANIZATION_SCHEMA_IRI,
374
+ CONTACT_SCHEMA_IRI,
375
+ RELATIONSHIP_SCHEMA_IRI,
376
+ PIPELINE_SCHEMA_IRI,
377
+ STAGE_SCHEMA_IRI,
378
+ DEAL_SCHEMA_IRI,
379
+ DEAL_CONTACT_ROLE_SCHEMA_IRI,
380
+ ACTIVITY_SCHEMA_IRI,
381
+ PRODUCT_SCHEMA_IRI,
382
+ LINE_ITEM_SCHEMA_IRI,
383
+ ORGANIZATION_SIZES,
384
+ OrganizationSchema,
385
+ CONTACT_LIFECYCLE,
386
+ ContactSchema,
387
+ RELATIONSHIP_KINDS,
388
+ RelationshipSchema,
389
+ PipelineSchema,
390
+ StageSchema,
391
+ FORECAST_CATEGORIES,
392
+ DEAL_SOURCES,
393
+ DealSchema,
394
+ DEAL_CONTACT_ROLES,
395
+ DealContactRoleSchema,
396
+ ACTIVITY_KINDS,
397
+ ActivitySchema,
398
+ PRODUCT_KINDS,
399
+ ProductSchema,
400
+ LineItemSchema,
401
+ crmSchemas
402
+ };
@@ -0,0 +1,45 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ defineSchema,
6
+ money,
7
+ relation,
8
+ select,
9
+ text
10
+ } from "./chunk-EBNMV2VO.js";
11
+
12
+ // src/schema/schemas/posting.ts
13
+ var POSTING_SCHEMA_IRI = "xnet://xnet.fyi/Posting@1.0.0";
14
+ var PostingSchema = defineSchema({
15
+ name: "Posting",
16
+ namespace: "xnet://xnet.fyi/",
17
+ properties: {
18
+ /** The owning journal entry. */
19
+ transaction: relation({ target: "xnet://xnet.fyi/Transaction@1.0.0", required: true }),
20
+ /** The account this leg debits/credits. */
21
+ account: relation({ target: "xnet://xnet.fyi/Account@1.0.0", required: true }),
22
+ /** Signed minor units + currency (debit positive / credit negative). */
23
+ amount: money({ required: true }),
24
+ /** Optional per-leg note (e.g. for split transactions). */
25
+ memo: text({ maxLength: 500 }),
26
+ /** Mirrors the transaction's Space so access cascades identically. */
27
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
28
+ /** Per-node visibility; defaults to `private` (financial data, 0187). */
29
+ visibility: select({
30
+ options: [
31
+ { id: "inherit", name: "Inherit", color: "gray" },
32
+ { id: "private", name: "Private", color: "gray" },
33
+ { id: "unlisted", name: "Unlisted", color: "yellow" },
34
+ { id: "public", name: "Public", color: "green" }
35
+ ],
36
+ default: "private"
37
+ })
38
+ },
39
+ authorization: spaceCascadeAuthorization()
40
+ });
41
+
42
+ export {
43
+ POSTING_SCHEMA_IRI,
44
+ PostingSchema
45
+ };