@endora-commerce/contracts 0.108.0 → 0.110.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/dist/actor.d.ts +16 -0
- package/dist/actor.d.ts.map +1 -1
- package/dist/addresses.d.ts +35 -0
- package/dist/addresses.d.ts.map +1 -1
- package/dist/addresses.js +8 -1
- package/dist/addresses.js.map +1 -1
- package/dist/admin-actions.d.ts +12 -3
- package/dist/admin-actions.d.ts.map +1 -1
- package/dist/admin-actions.js +34 -3
- package/dist/admin-actions.js.map +1 -1
- package/dist/admin-contributions.d.ts +94 -10
- package/dist/admin-contributions.d.ts.map +1 -1
- package/dist/admin-contributions.js +65 -0
- package/dist/admin-contributions.js.map +1 -1
- package/dist/admin-notifications.d.ts +17 -1
- package/dist/admin-notifications.d.ts.map +1 -1
- package/dist/admin-preferences.d.ts +108 -0
- package/dist/admin-preferences.d.ts.map +1 -0
- package/dist/admin-preferences.js +133 -0
- package/dist/admin-preferences.js.map +1 -0
- package/dist/admin-roles.d.ts +8 -2
- package/dist/admin-roles.d.ts.map +1 -1
- package/dist/admin-roles.js.map +1 -1
- package/dist/admin-users.d.ts +9 -0
- package/dist/admin-users.d.ts.map +1 -1
- package/dist/admin.d.ts +92 -5
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +86 -3
- package/dist/admin.js.map +1 -1
- package/dist/assets-library.d.ts +123 -3
- package/dist/assets-library.d.ts.map +1 -1
- package/dist/assets-library.js +11 -3
- package/dist/assets-library.js.map +1 -1
- package/dist/audit-logs.d.ts +12 -0
- package/dist/audit-logs.d.ts.map +1 -1
- package/dist/audit-logs.js +12 -0
- package/dist/audit-logs.js.map +1 -1
- package/dist/blog.d.ts +431 -14
- package/dist/blog.d.ts.map +1 -1
- package/dist/blog.js +251 -7
- package/dist/blog.js.map +1 -1
- package/dist/carts.d.ts +507 -92
- package/dist/carts.d.ts.map +1 -1
- package/dist/carts.js +197 -21
- package/dist/carts.js.map +1 -1
- package/dist/catalog.d.ts +515 -144
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +356 -68
- package/dist/catalog.js.map +1 -1
- package/dist/cms-brand.d.ts +2233 -0
- package/dist/cms-brand.d.ts.map +1 -0
- package/dist/cms-brand.js +311 -0
- package/dist/cms-brand.js.map +1 -0
- package/dist/cms-contact-form.d.ts +55 -0
- package/dist/cms-contact-form.d.ts.map +1 -0
- package/dist/cms-contact-form.js +100 -0
- package/dist/cms-contact-form.js.map +1 -0
- package/dist/cms.d.ts +576 -17
- package/dist/cms.d.ts.map +1 -1
- package/dist/cms.js +251 -0
- package/dist/cms.js.map +1 -1
- package/dist/common.d.ts +23 -6
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +25 -2
- package/dist/common.js.map +1 -1
- package/dist/comparisons.d.ts +28 -21
- package/dist/comparisons.d.ts.map +1 -1
- package/dist/comparisons.js +2 -1
- package/dist/comparisons.js.map +1 -1
- package/dist/credit-limits.d.ts +1 -0
- package/dist/credit-limits.d.ts.map +1 -1
- package/dist/credit-limits.js +14 -0
- package/dist/credit-limits.js.map +1 -1
- package/dist/crm-rich-text.d.ts +10 -61
- package/dist/crm-rich-text.d.ts.map +1 -1
- package/dist/crm-rich-text.js +10 -300
- package/dist/crm-rich-text.js.map +1 -1
- package/dist/crm.d.ts +173 -115
- package/dist/crm.d.ts.map +1 -1
- package/dist/crm.js +35 -88
- package/dist/crm.js.map +1 -1
- package/dist/custom-fields.d.ts +54 -22
- package/dist/custom-fields.d.ts.map +1 -1
- package/dist/custom-fields.js +21 -1
- package/dist/custom-fields.js.map +1 -1
- package/dist/customer-accounts.d.ts +216 -22
- package/dist/customer-accounts.d.ts.map +1 -1
- package/dist/customer-accounts.js +70 -0
- package/dist/customer-accounts.js.map +1 -1
- package/dist/customers.d.ts +40 -73
- package/dist/customers.d.ts.map +1 -1
- package/dist/customers.js +45 -10
- package/dist/customers.js.map +1 -1
- package/dist/document-templates.d.ts +35 -23
- package/dist/document-templates.d.ts.map +1 -1
- package/dist/document-values.d.ts +8 -0
- package/dist/document-values.d.ts.map +1 -1
- package/dist/document-values.js +24 -6
- package/dist/document-values.js.map +1 -1
- package/dist/email.d.ts +5 -0
- package/dist/email.d.ts.map +1 -1
- package/dist/errors.d.ts +224 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +269 -1
- package/dist/errors.js.map +1 -1
- package/dist/forms-logic.d.ts +79 -0
- package/dist/forms-logic.d.ts.map +1 -0
- package/dist/forms-logic.fixtures.d.ts +52 -0
- package/dist/forms-logic.fixtures.d.ts.map +1 -0
- package/dist/forms-logic.fixtures.js +610 -0
- package/dist/forms-logic.fixtures.js.map +1 -0
- package/dist/forms-logic.js +699 -0
- package/dist/forms-logic.js.map +1 -0
- package/dist/forms.d.ts +9833 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +827 -0
- package/dist/forms.js.map +1 -0
- package/dist/import-export.d.ts +180 -0
- package/dist/import-export.d.ts.map +1 -1
- package/dist/import-export.js +60 -0
- package/dist/import-export.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/inventory.d.ts +6 -6
- package/dist/invoice-ledger.d.ts +7 -7
- package/dist/invoices.d.ts +6 -2
- package/dist/invoices.d.ts.map +1 -1
- package/dist/invoices.js +7 -0
- package/dist/invoices.js.map +1 -1
- package/dist/megamenu.d.ts +674 -0
- package/dist/megamenu.d.ts.map +1 -1
- package/dist/megamenu.js +96 -3
- package/dist/megamenu.js.map +1 -1
- package/dist/mfa.d.ts +125 -4
- package/dist/mfa.d.ts.map +1 -1
- package/dist/mfa.js +54 -2
- package/dist/mfa.js.map +1 -1
- package/dist/modules.d.ts +44 -5
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +73 -0
- package/dist/modules.js.map +1 -1
- package/dist/money-decimal.d.ts +54 -0
- package/dist/money-decimal.d.ts.map +1 -1
- package/dist/money-decimal.js +95 -0
- package/dist/money-decimal.js.map +1 -1
- package/dist/newsletter.d.ts +7 -7
- package/dist/orders.d.ts +128 -10
- package/dist/orders.d.ts.map +1 -1
- package/dist/orders.js +74 -4
- package/dist/orders.js.map +1 -1
- package/dist/organization-registry-lookup.d.ts +362 -0
- package/dist/organization-registry-lookup.d.ts.map +1 -0
- package/dist/organization-registry-lookup.js +196 -0
- package/dist/organization-registry-lookup.js.map +1 -0
- package/dist/organization-roles.d.ts +340 -0
- package/dist/organization-roles.d.ts.map +1 -0
- package/dist/organization-roles.js +211 -0
- package/dist/organization-roles.js.map +1 -0
- package/dist/organizations.d.ts +123 -89
- package/dist/organizations.d.ts.map +1 -1
- package/dist/organizations.js +68 -24
- package/dist/organizations.js.map +1 -1
- package/dist/page-builder-props.d.ts +1401 -0
- package/dist/page-builder-props.d.ts.map +1 -0
- package/dist/page-builder-props.js +266 -0
- package/dist/page-builder-props.js.map +1 -0
- package/dist/page-builder-values.d.ts +95 -0
- package/dist/page-builder-values.d.ts.map +1 -0
- package/dist/page-builder-values.js +164 -0
- package/dist/page-builder-values.js.map +1 -0
- package/dist/pim-connector.d.ts +6 -2
- package/dist/pim-connector.d.ts.map +1 -1
- package/dist/pim-connector.js +6 -2
- package/dist/pim-connector.js.map +1 -1
- package/dist/pim-field-path.d.ts +5 -1
- package/dist/pim-field-path.d.ts.map +1 -1
- package/dist/pim-field-path.js +37 -81
- package/dist/pim-field-path.js.map +1 -1
- package/dist/pim-locale-mapping.d.ts +131 -0
- package/dist/pim-locale-mapping.d.ts.map +1 -0
- package/dist/pim-locale-mapping.js +193 -0
- package/dist/pim-locale-mapping.js.map +1 -0
- package/dist/platform-language.d.ts +9 -0
- package/dist/platform-language.d.ts.map +1 -1
- package/dist/platform-language.js +14 -0
- package/dist/platform-language.js.map +1 -1
- package/dist/price-books.d.ts +47 -43
- package/dist/price-books.d.ts.map +1 -1
- package/dist/price-books.js +6 -2
- package/dist/price-books.js.map +1 -1
- package/dist/price-lists.d.ts +48 -14
- package/dist/price-lists.d.ts.map +1 -1
- package/dist/price-lists.js +24 -1
- package/dist/price-lists.js.map +1 -1
- package/dist/product-feeds.d.ts +144 -84
- package/dist/product-feeds.d.ts.map +1 -1
- package/dist/product-feeds.js +23 -0
- package/dist/product-feeds.js.map +1 -1
- package/dist/product-scope-model.d.ts +161 -0
- package/dist/product-scope-model.d.ts.map +1 -0
- package/dist/product-scope-model.js +161 -0
- package/dist/product-scope-model.js.map +1 -0
- package/dist/product-scope-overrides.d.ts +0 -103
- package/dist/product-scope-overrides.d.ts.map +1 -1
- package/dist/product-scope-overrides.js +0 -54
- package/dist/product-scope-overrides.js.map +1 -1
- package/dist/product-scoped-values.d.ts +2610 -0
- package/dist/product-scoped-values.d.ts.map +1 -0
- package/dist/product-scoped-values.js +425 -0
- package/dist/product-scoped-values.js.map +1 -0
- package/dist/product-scopes.d.ts +746 -0
- package/dist/product-scopes.d.ts.map +1 -0
- package/dist/product-scopes.js +436 -0
- package/dist/product-scopes.js.map +1 -0
- package/dist/product-summary-text.d.ts +23 -0
- package/dist/product-summary-text.d.ts.map +1 -0
- package/dist/product-summary-text.js +64 -0
- package/dist/product-summary-text.js.map +1 -0
- package/dist/product-tax-rates.d.ts +38 -0
- package/dist/product-tax-rates.d.ts.map +1 -0
- package/dist/product-tax-rates.js +45 -0
- package/dist/product-tax-rates.js.map +1 -0
- package/dist/product-url-keys.d.ts +210 -0
- package/dist/product-url-keys.d.ts.map +1 -0
- package/dist/product-url-keys.js +200 -0
- package/dist/product-url-keys.js.map +1 -0
- package/dist/product-value-resolver.d.ts +37 -60
- package/dist/product-value-resolver.d.ts.map +1 -1
- package/dist/product-value-resolver.js +36 -96
- package/dist/product-value-resolver.js.map +1 -1
- package/dist/projects.d.ts +2370 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +843 -0
- package/dist/projects.js.map +1 -0
- package/dist/promotions.d.ts +10 -10
- package/dist/prompt-actions.d.ts +19 -1
- package/dist/prompt-actions.d.ts.map +1 -1
- package/dist/prompt-actions.js +31 -2
- package/dist/prompt-actions.js.map +1 -1
- package/dist/pwa.d.ts +2 -2
- package/dist/quick-order.d.ts +150 -7
- package/dist/quick-order.d.ts.map +1 -1
- package/dist/quick-order.js +76 -2
- package/dist/quick-order.js.map +1 -1
- package/dist/quote-requests.d.ts +99 -13
- package/dist/quote-requests.d.ts.map +1 -1
- package/dist/quote-requests.js +66 -1
- package/dist/quote-requests.js.map +1 -1
- package/dist/record-references.d.ts +252 -0
- package/dist/record-references.d.ts.map +1 -0
- package/dist/record-references.js +178 -0
- package/dist/record-references.js.map +1 -0
- package/dist/record-rich-text.d.ts +66 -0
- package/dist/record-rich-text.d.ts.map +1 -0
- package/dist/record-rich-text.js +304 -0
- package/dist/record-rich-text.js.map +1 -0
- package/dist/returns.d.ts +234 -52
- package/dist/returns.d.ts.map +1 -1
- package/dist/returns.js +139 -26
- package/dist/returns.js.map +1 -1
- package/dist/sales-channels.d.ts +51 -7
- package/dist/sales-channels.d.ts.map +1 -1
- package/dist/sales-channels.js +38 -4
- package/dist/sales-channels.js.map +1 -1
- package/dist/saved-list-views.d.ts +56 -0
- package/dist/saved-list-views.d.ts.map +1 -1
- package/dist/saved-list-views.js +27 -1
- package/dist/saved-list-views.js.map +1 -1
- package/dist/scoped-write-encoding.d.ts +100 -0
- package/dist/scoped-write-encoding.d.ts.map +1 -0
- package/dist/scoped-write-encoding.js +135 -0
- package/dist/scoped-write-encoding.js.map +1 -0
- package/dist/search.d.ts +25 -15
- package/dist/search.d.ts.map +1 -1
- package/dist/seo.d.ts +127 -15
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +38 -4
- package/dist/seo.js.map +1 -1
- package/dist/settings.d.ts +161 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +73 -3
- package/dist/settings.js.map +1 -1
- package/dist/shopping-lists.d.ts +24 -3
- package/dist/shopping-lists.d.ts.map +1 -1
- package/dist/shopping-lists.js +20 -0
- package/dist/shopping-lists.js.map +1 -1
- package/dist/storefront-cache-tags.d.ts +41 -0
- package/dist/storefront-cache-tags.d.ts.map +1 -1
- package/dist/storefront-cache-tags.js +36 -0
- package/dist/storefront-cache-tags.js.map +1 -1
- package/dist/storefront-language-path.d.ts +77 -0
- package/dist/storefront-language-path.d.ts.map +1 -0
- package/dist/storefront-language-path.js +123 -0
- package/dist/storefront-language-path.js.map +1 -0
- package/dist/storefront-value-overrides.d.ts +18 -56
- package/dist/storefront-value-overrides.d.ts.map +1 -1
- package/dist/storefront-value-overrides.js +11 -86
- package/dist/storefront-value-overrides.js.map +1 -1
- package/dist/tasks.d.ts +2842 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +901 -0
- package/dist/tasks.js.map +1 -0
- package/dist/transactional-emails.d.ts +14 -11
- package/dist/transactional-emails.d.ts.map +1 -1
- package/dist/transactional-emails.js +13 -0
- package/dist/transactional-emails.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The reference standard of every record's free text — an Opportunity's, a
|
|
4
|
+
* Project's, a Task's (`specs/163-projects-and-tasks/` research R-14, FR-044).
|
|
5
|
+
*
|
|
6
|
+
* Free text (a description, a note's or a message's body) is stored as plain
|
|
7
|
+
* text carrying `[[<type>:<uuid>]]` tokens. This is the one place the grammar is
|
|
8
|
+
* written; a backend extracts with it and an admin composer inserts with it.
|
|
9
|
+
* What a person types to get one — `@` a person, `@@` a document (an Order, a
|
|
10
|
+
* Quote Request, a Task, an Opportunity or a Project, in one grouped list),
|
|
11
|
+
* `@@@` a Product — is the composer's and is never stored.
|
|
12
|
+
*
|
|
13
|
+
* The grammar was CRM's (`crm.ts` §9, three types) and moved here under neutral
|
|
14
|
+
* names when Projects became its second user; CRM's exported names are aliases
|
|
15
|
+
* of these, so a text CRM stored before reads exactly as it did — its tokens are
|
|
16
|
+
* a subset of the seven.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* What a free text can refer to. `admin_user` is a person — a user of the Admin
|
|
20
|
+
* UI, under the name the platform has for one everywhere else; `user` alone
|
|
21
|
+
* would also read as a customer.
|
|
22
|
+
*/
|
|
23
|
+
export declare const RECORD_REFERENCE_TYPES: readonly ["product", "order", "admin_user", "quote_request", "task", "opportunity", "project"];
|
|
24
|
+
export declare const recordReferenceTypeSchema: z.ZodEnum<{
|
|
25
|
+
product: "product";
|
|
26
|
+
order: "order";
|
|
27
|
+
admin_user: "admin_user";
|
|
28
|
+
quote_request: "quote_request";
|
|
29
|
+
task: "task";
|
|
30
|
+
opportunity: "opportunity";
|
|
31
|
+
project: "project";
|
|
32
|
+
}>;
|
|
33
|
+
export type RecordReferenceType = z.infer<typeof recordReferenceTypeSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* The source of the token expression — group 1 the type, group 2 the id. A
|
|
36
|
+
* source and not a shared `RegExp`, because a global expression carries
|
|
37
|
+
* `lastIndex` from one caller to the next: build a fresh one per use.
|
|
38
|
+
*/
|
|
39
|
+
export declare const REFERENCE_TOKEN_SOURCE: string;
|
|
40
|
+
export interface RecordReferenceToken {
|
|
41
|
+
type: RecordReferenceType;
|
|
42
|
+
id: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function formatRecordReferenceToken(type: RecordReferenceType, id: string): string;
|
|
45
|
+
/** Every well-formed token in `text`, in first-appearance order, each target once. */
|
|
46
|
+
export declare function extractRecordReferenceTokens(text: string): RecordReferenceToken[];
|
|
47
|
+
/** A stretch of plain text, or one well-formed token, in the order they appear. */
|
|
48
|
+
export type RecordReferenceTextPart = {
|
|
49
|
+
kind: 'text';
|
|
50
|
+
text: string;
|
|
51
|
+
} | ({
|
|
52
|
+
kind: 'reference';
|
|
53
|
+
} & RecordReferenceToken);
|
|
54
|
+
/**
|
|
55
|
+
* `text` cut at its well-formed tokens, for a screen that shows each token as
|
|
56
|
+
* a link: the parts, joined back, are the text. A malformed token, or one of a
|
|
57
|
+
* type outside the seven, stays text.
|
|
58
|
+
*/
|
|
59
|
+
export declare function splitRecordReferenceText(text: string): RecordReferenceTextPart[];
|
|
60
|
+
/** The people a text mentions, each once, in first-appearance order. */
|
|
61
|
+
export declare function mentionedAdminUserIds(text: string | null | undefined): string[];
|
|
62
|
+
/**
|
|
63
|
+
* What an available Order reference says beyond its number
|
|
64
|
+
* (`specs/158-crm-opportunity-inline-editing/`, FR-012): its status code — the
|
|
65
|
+
* screen names it from `orders`' statuses — its total, when it was placed and
|
|
66
|
+
* for whom (the billing company, else the billing recipient).
|
|
67
|
+
*/
|
|
68
|
+
export declare const RecordReferenceOrderSchema: z.ZodObject<{
|
|
69
|
+
status: z.ZodString;
|
|
70
|
+
total: z.ZodString;
|
|
71
|
+
currency: z.ZodString;
|
|
72
|
+
placedAt: z.ZodString;
|
|
73
|
+
customerName: z.ZodNullable<z.ZodString>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type RecordReferenceOrder = z.infer<typeof RecordReferenceOrderSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* A resolved reference, returned beside every free-text field. A target the
|
|
78
|
+
* reader may not see, that is gone, or whose owning module is switched off is
|
|
79
|
+
* `available: false` with no label. A person has a `label` — their name — and
|
|
80
|
+
* never a `url`: the screen of an administrator is `admin_users`', behind a
|
|
81
|
+
* permission of its own.
|
|
82
|
+
*/
|
|
83
|
+
export declare const RecordReferenceSchema: z.ZodObject<{
|
|
84
|
+
type: z.ZodEnum<{
|
|
85
|
+
product: "product";
|
|
86
|
+
order: "order";
|
|
87
|
+
admin_user: "admin_user";
|
|
88
|
+
quote_request: "quote_request";
|
|
89
|
+
task: "task";
|
|
90
|
+
opportunity: "opportunity";
|
|
91
|
+
project: "project";
|
|
92
|
+
}>;
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
available: z.ZodBoolean;
|
|
95
|
+
label: z.ZodNullable<z.ZodString>;
|
|
96
|
+
url: z.ZodNullable<z.ZodString>;
|
|
97
|
+
order: z.ZodOptional<z.ZodObject<{
|
|
98
|
+
status: z.ZodString;
|
|
99
|
+
total: z.ZodString;
|
|
100
|
+
currency: z.ZodString;
|
|
101
|
+
placedAt: z.ZodString;
|
|
102
|
+
customerName: z.ZodNullable<z.ZodString>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
export type RecordReference = z.infer<typeof RecordReferenceSchema>;
|
|
106
|
+
/**
|
|
107
|
+
* The kinds the `@@` list groups, in the order it shows them. Opportunities and
|
|
108
|
+
* Projects joined in `specs/165-task-management/` (R-5).
|
|
109
|
+
*/
|
|
110
|
+
export declare const RECORD_DOCUMENT_KINDS: readonly ["order", "quote_request", "task", "opportunity", "project"];
|
|
111
|
+
export declare const recordDocumentKindSchema: z.ZodEnum<{
|
|
112
|
+
order: "order";
|
|
113
|
+
quote_request: "quote_request";
|
|
114
|
+
task: "task";
|
|
115
|
+
opportunity: "opportunity";
|
|
116
|
+
project: "project";
|
|
117
|
+
}>;
|
|
118
|
+
export type RecordDocumentKind = z.infer<typeof recordDocumentKindSchema>;
|
|
119
|
+
export declare const RecordDocumentLookupItemSchema: z.ZodObject<{
|
|
120
|
+
id: z.ZodString;
|
|
121
|
+
label: z.ZodString;
|
|
122
|
+
sublabel: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
export type RecordDocumentLookupItem = z.infer<typeof RecordDocumentLookupItemSchema>;
|
|
125
|
+
export declare const RecordDocumentLookupGroupSchema: z.ZodObject<{
|
|
126
|
+
kind: z.ZodEnum<{
|
|
127
|
+
order: "order";
|
|
128
|
+
quote_request: "quote_request";
|
|
129
|
+
task: "task";
|
|
130
|
+
opportunity: "opportunity";
|
|
131
|
+
project: "project";
|
|
132
|
+
}>;
|
|
133
|
+
items: z.ZodArray<z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
label: z.ZodString;
|
|
136
|
+
sublabel: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
export type RecordDocumentLookupGroup = z.infer<typeof RecordDocumentLookupGroupSchema>;
|
|
140
|
+
/**
|
|
141
|
+
* The answer of `GET /projects/lookups/documents` and of
|
|
142
|
+
* `GET /crm/lookups/documents` — one schema for both (FR-044). A group is
|
|
143
|
+
* present only for a kind whose owning module is present and whose read
|
|
144
|
+
* permission the caller holds (`orders:read`, `rfqs:handle`, `tasks:read`,
|
|
145
|
+
* `crm:read`, `projects:read`).
|
|
146
|
+
*/
|
|
147
|
+
export declare const RecordDocumentLookupResponseSchema: z.ZodObject<{
|
|
148
|
+
groups: z.ZodArray<z.ZodObject<{
|
|
149
|
+
kind: z.ZodEnum<{
|
|
150
|
+
order: "order";
|
|
151
|
+
quote_request: "quote_request";
|
|
152
|
+
task: "task";
|
|
153
|
+
opportunity: "opportunity";
|
|
154
|
+
project: "project";
|
|
155
|
+
}>;
|
|
156
|
+
items: z.ZodArray<z.ZodObject<{
|
|
157
|
+
id: z.ZodString;
|
|
158
|
+
label: z.ZodString;
|
|
159
|
+
sublabel: z.ZodOptional<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
export type RecordDocumentLookupResponse = z.infer<typeof RecordDocumentLookupResponseSchema>;
|
|
164
|
+
export declare const RecordHistoryQuerySchema: z.ZodObject<{
|
|
165
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
166
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
export type RecordHistoryQuery = z.infer<typeof RecordHistoryQuerySchema>;
|
|
169
|
+
export declare const RecordHistoryEntrySchema: z.ZodObject<{
|
|
170
|
+
id: z.ZodString;
|
|
171
|
+
actedAt: z.ZodString;
|
|
172
|
+
action: z.ZodString;
|
|
173
|
+
actor: z.ZodObject<{
|
|
174
|
+
kind: z.ZodString;
|
|
175
|
+
id: z.ZodNullable<z.ZodString>;
|
|
176
|
+
name: z.ZodNullable<z.ZodString>;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
before: z.ZodNullable<z.ZodUnknown>;
|
|
179
|
+
after: z.ZodNullable<z.ZodUnknown>;
|
|
180
|
+
references: z.ZodArray<z.ZodObject<{
|
|
181
|
+
type: z.ZodEnum<{
|
|
182
|
+
product: "product";
|
|
183
|
+
order: "order";
|
|
184
|
+
admin_user: "admin_user";
|
|
185
|
+
quote_request: "quote_request";
|
|
186
|
+
task: "task";
|
|
187
|
+
opportunity: "opportunity";
|
|
188
|
+
project: "project";
|
|
189
|
+
}>;
|
|
190
|
+
id: z.ZodString;
|
|
191
|
+
available: z.ZodBoolean;
|
|
192
|
+
label: z.ZodNullable<z.ZodString>;
|
|
193
|
+
url: z.ZodNullable<z.ZodString>;
|
|
194
|
+
order: z.ZodOptional<z.ZodObject<{
|
|
195
|
+
status: z.ZodString;
|
|
196
|
+
total: z.ZodString;
|
|
197
|
+
currency: z.ZodString;
|
|
198
|
+
placedAt: z.ZodString;
|
|
199
|
+
customerName: z.ZodNullable<z.ZodString>;
|
|
200
|
+
}, z.core.$strip>>;
|
|
201
|
+
}, z.core.$strip>>;
|
|
202
|
+
}, z.core.$strip>;
|
|
203
|
+
export type RecordHistoryEntry = z.infer<typeof RecordHistoryEntrySchema>;
|
|
204
|
+
/**
|
|
205
|
+
* `truncated` is beside `pagination` and not part of it: it is `true` on the
|
|
206
|
+
* last page a history can serve when the record has earlier entries beyond the
|
|
207
|
+
* cap it reaches back to (CRM's `OpportunityHistoryResponse`, the same shape).
|
|
208
|
+
*/
|
|
209
|
+
export declare const RecordHistoryPageSchema: z.ZodObject<{
|
|
210
|
+
data: z.ZodArray<z.ZodObject<{
|
|
211
|
+
id: z.ZodString;
|
|
212
|
+
actedAt: z.ZodString;
|
|
213
|
+
action: z.ZodString;
|
|
214
|
+
actor: z.ZodObject<{
|
|
215
|
+
kind: z.ZodString;
|
|
216
|
+
id: z.ZodNullable<z.ZodString>;
|
|
217
|
+
name: z.ZodNullable<z.ZodString>;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
before: z.ZodNullable<z.ZodUnknown>;
|
|
220
|
+
after: z.ZodNullable<z.ZodUnknown>;
|
|
221
|
+
references: z.ZodArray<z.ZodObject<{
|
|
222
|
+
type: z.ZodEnum<{
|
|
223
|
+
product: "product";
|
|
224
|
+
order: "order";
|
|
225
|
+
admin_user: "admin_user";
|
|
226
|
+
quote_request: "quote_request";
|
|
227
|
+
task: "task";
|
|
228
|
+
opportunity: "opportunity";
|
|
229
|
+
project: "project";
|
|
230
|
+
}>;
|
|
231
|
+
id: z.ZodString;
|
|
232
|
+
available: z.ZodBoolean;
|
|
233
|
+
label: z.ZodNullable<z.ZodString>;
|
|
234
|
+
url: z.ZodNullable<z.ZodString>;
|
|
235
|
+
order: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
status: z.ZodString;
|
|
237
|
+
total: z.ZodString;
|
|
238
|
+
currency: z.ZodString;
|
|
239
|
+
placedAt: z.ZodString;
|
|
240
|
+
customerName: z.ZodNullable<z.ZodString>;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
}, z.core.$strip>>;
|
|
243
|
+
}, z.core.$strip>>;
|
|
244
|
+
pagination: z.ZodObject<{
|
|
245
|
+
cursor: z.ZodNullable<z.ZodString>;
|
|
246
|
+
hasMore: z.ZodBoolean;
|
|
247
|
+
limit: z.ZodNumber;
|
|
248
|
+
}, z.core.$strip>;
|
|
249
|
+
truncated: z.ZodBoolean;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
export type RecordHistoryPage = z.infer<typeof RecordHistoryPageSchema>;
|
|
252
|
+
//# sourceMappingURL=record-references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-references.d.ts","sourceRoot":"","sources":["../src/record-references.ts"],"names":[],"mappings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
|
|
3
|
+
import { collectionEnvelope } from './envelopes.js';
|
|
4
|
+
/**
|
|
5
|
+
* The reference standard of every record's free text — an Opportunity's, a
|
|
6
|
+
* Project's, a Task's (`specs/163-projects-and-tasks/` research R-14, FR-044).
|
|
7
|
+
*
|
|
8
|
+
* Free text (a description, a note's or a message's body) is stored as plain
|
|
9
|
+
* text carrying `[[<type>:<uuid>]]` tokens. This is the one place the grammar is
|
|
10
|
+
* written; a backend extracts with it and an admin composer inserts with it.
|
|
11
|
+
* What a person types to get one — `@` a person, `@@` a document (an Order, a
|
|
12
|
+
* Quote Request, a Task, an Opportunity or a Project, in one grouped list),
|
|
13
|
+
* `@@@` a Product — is the composer's and is never stored.
|
|
14
|
+
*
|
|
15
|
+
* The grammar was CRM's (`crm.ts` §9, three types) and moved here under neutral
|
|
16
|
+
* names when Projects became its second user; CRM's exported names are aliases
|
|
17
|
+
* of these, so a text CRM stored before reads exactly as it did — its tokens are
|
|
18
|
+
* a subset of the seven.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* What a free text can refer to. `admin_user` is a person — a user of the Admin
|
|
22
|
+
* UI, under the name the platform has for one everywhere else; `user` alone
|
|
23
|
+
* would also read as a customer.
|
|
24
|
+
*/
|
|
25
|
+
export const RECORD_REFERENCE_TYPES = [
|
|
26
|
+
'product',
|
|
27
|
+
'order',
|
|
28
|
+
'admin_user',
|
|
29
|
+
'quote_request',
|
|
30
|
+
'task',
|
|
31
|
+
// `specs/165-task-management/` research R-5 — platform-wide, so CRM's and
|
|
32
|
+
// Projects' extractors recognise them too and their reference checks widen.
|
|
33
|
+
'opportunity',
|
|
34
|
+
'project',
|
|
35
|
+
];
|
|
36
|
+
export const recordReferenceTypeSchema = z.enum(RECORD_REFERENCE_TYPES);
|
|
37
|
+
/**
|
|
38
|
+
* The source of the token expression — group 1 the type, group 2 the id. A
|
|
39
|
+
* source and not a shared `RegExp`, because a global expression carries
|
|
40
|
+
* `lastIndex` from one caller to the next: build a fresh one per use.
|
|
41
|
+
*/
|
|
42
|
+
export const REFERENCE_TOKEN_SOURCE = `\\[\\[(${RECORD_REFERENCE_TYPES.join('|')}):(${UUID_SHAPE_PATTERN})\\]\\]`;
|
|
43
|
+
export function formatRecordReferenceToken(type, id) {
|
|
44
|
+
return `[[${type}:${id}]]`;
|
|
45
|
+
}
|
|
46
|
+
/** Every well-formed token in `text`, in first-appearance order, each target once. */
|
|
47
|
+
export function extractRecordReferenceTokens(text) {
|
|
48
|
+
const seen = new Set();
|
|
49
|
+
const tokens = [];
|
|
50
|
+
for (const match of text.matchAll(new RegExp(REFERENCE_TOKEN_SOURCE, 'g'))) {
|
|
51
|
+
const type = match[1];
|
|
52
|
+
const id = match[2].toLowerCase();
|
|
53
|
+
const key = `${type}:${id}`;
|
|
54
|
+
if (seen.has(key))
|
|
55
|
+
continue;
|
|
56
|
+
seen.add(key);
|
|
57
|
+
tokens.push({ type, id });
|
|
58
|
+
}
|
|
59
|
+
return tokens;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `text` cut at its well-formed tokens, for a screen that shows each token as
|
|
63
|
+
* a link: the parts, joined back, are the text. A malformed token, or one of a
|
|
64
|
+
* type outside the seven, stays text.
|
|
65
|
+
*/
|
|
66
|
+
export function splitRecordReferenceText(text) {
|
|
67
|
+
const parts = [];
|
|
68
|
+
let cursor = 0;
|
|
69
|
+
for (const match of text.matchAll(new RegExp(REFERENCE_TOKEN_SOURCE, 'g'))) {
|
|
70
|
+
const start = match.index ?? 0;
|
|
71
|
+
if (start > cursor)
|
|
72
|
+
parts.push({ kind: 'text', text: text.slice(cursor, start) });
|
|
73
|
+
parts.push({
|
|
74
|
+
kind: 'reference',
|
|
75
|
+
type: match[1],
|
|
76
|
+
id: match[2].toLowerCase(),
|
|
77
|
+
});
|
|
78
|
+
cursor = start + match[0].length;
|
|
79
|
+
}
|
|
80
|
+
if (cursor < text.length)
|
|
81
|
+
parts.push({ kind: 'text', text: text.slice(cursor) });
|
|
82
|
+
return parts;
|
|
83
|
+
}
|
|
84
|
+
/** The people a text mentions, each once, in first-appearance order. */
|
|
85
|
+
export function mentionedAdminUserIds(text) {
|
|
86
|
+
if (!text)
|
|
87
|
+
return [];
|
|
88
|
+
return extractRecordReferenceTokens(text)
|
|
89
|
+
.filter((token) => token.type === 'admin_user')
|
|
90
|
+
.map((token) => token.id);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What an available Order reference says beyond its number
|
|
94
|
+
* (`specs/158-crm-opportunity-inline-editing/`, FR-012): its status code — the
|
|
95
|
+
* screen names it from `orders`' statuses — its total, when it was placed and
|
|
96
|
+
* for whom (the billing company, else the billing recipient).
|
|
97
|
+
*/
|
|
98
|
+
export const RecordReferenceOrderSchema = z.object({
|
|
99
|
+
status: z.string(),
|
|
100
|
+
total: z.string(),
|
|
101
|
+
currency: z.string(),
|
|
102
|
+
placedAt: z.string(),
|
|
103
|
+
customerName: z.string().nullable(),
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* A resolved reference, returned beside every free-text field. A target the
|
|
107
|
+
* reader may not see, that is gone, or whose owning module is switched off is
|
|
108
|
+
* `available: false` with no label. A person has a `label` — their name — and
|
|
109
|
+
* never a `url`: the screen of an administrator is `admin_users`', behind a
|
|
110
|
+
* permission of its own.
|
|
111
|
+
*/
|
|
112
|
+
export const RecordReferenceSchema = z.object({
|
|
113
|
+
type: recordReferenceTypeSchema,
|
|
114
|
+
id: z.string().uuid(),
|
|
115
|
+
available: z.boolean(),
|
|
116
|
+
label: z.string().nullable(),
|
|
117
|
+
url: z.string().nullable(),
|
|
118
|
+
/** Present on an available Order only. */
|
|
119
|
+
order: RecordReferenceOrderSchema.optional(),
|
|
120
|
+
});
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// The `@@` document list (FR-044)
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
/**
|
|
125
|
+
* The kinds the `@@` list groups, in the order it shows them. Opportunities and
|
|
126
|
+
* Projects joined in `specs/165-task-management/` (R-5).
|
|
127
|
+
*/
|
|
128
|
+
export const RECORD_DOCUMENT_KINDS = ['order', 'quote_request', 'task', 'opportunity', 'project'];
|
|
129
|
+
export const recordDocumentKindSchema = z.enum(RECORD_DOCUMENT_KINDS);
|
|
130
|
+
export const RecordDocumentLookupItemSchema = z.object({
|
|
131
|
+
id: z.string().uuid(),
|
|
132
|
+
label: z.string(),
|
|
133
|
+
sublabel: z.string().optional(),
|
|
134
|
+
});
|
|
135
|
+
export const RecordDocumentLookupGroupSchema = z.object({
|
|
136
|
+
kind: recordDocumentKindSchema,
|
|
137
|
+
items: z.array(RecordDocumentLookupItemSchema),
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* The answer of `GET /projects/lookups/documents` and of
|
|
141
|
+
* `GET /crm/lookups/documents` — one schema for both (FR-044). A group is
|
|
142
|
+
* present only for a kind whose owning module is present and whose read
|
|
143
|
+
* permission the caller holds (`orders:read`, `rfqs:handle`, `tasks:read`,
|
|
144
|
+
* `crm:read`, `projects:read`).
|
|
145
|
+
*/
|
|
146
|
+
export const RecordDocumentLookupResponseSchema = z.object({
|
|
147
|
+
groups: z.array(RecordDocumentLookupGroupSchema),
|
|
148
|
+
});
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
// A record's history page — the audit trail of one record, read by its owner
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
export const RecordHistoryQuerySchema = z.object({
|
|
153
|
+
limit: z.coerce.number().int().positive().max(200).default(50),
|
|
154
|
+
cursor: z.string().optional(),
|
|
155
|
+
});
|
|
156
|
+
export const RecordHistoryEntrySchema = z.object({
|
|
157
|
+
id: z.string(),
|
|
158
|
+
actedAt: z.string(),
|
|
159
|
+
action: z.string(),
|
|
160
|
+
actor: z.object({
|
|
161
|
+
kind: z.string(),
|
|
162
|
+
id: z.string().nullable(),
|
|
163
|
+
name: z.string().nullable(),
|
|
164
|
+
}),
|
|
165
|
+
before: z.unknown().nullable(),
|
|
166
|
+
after: z.unknown().nullable(),
|
|
167
|
+
/** What the tokens in this entry's texts name for this reader, so the history shows names. */
|
|
168
|
+
references: z.array(RecordReferenceSchema),
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* `truncated` is beside `pagination` and not part of it: it is `true` on the
|
|
172
|
+
* last page a history can serve when the record has earlier entries beyond the
|
|
173
|
+
* cap it reaches back to (CRM's `OpportunityHistoryResponse`, the same shape).
|
|
174
|
+
*/
|
|
175
|
+
export const RecordHistoryPageSchema = collectionEnvelope(RecordHistoryEntrySchema).extend({
|
|
176
|
+
truncated: z.boolean(),
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=record-references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-references.js","sourceRoot":"","sources":["../src/record-references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS;IACT,OAAO;IACP,YAAY;IACZ,eAAe;IACf,MAAM;IACN,0EAA0E;IAC1E,4EAA4E;IAC5E,aAAa;IACb,SAAS;CACD,CAAC;AACX,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAGxE;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,kBAAkB,SAAS,CAAC;AAOlH,MAAM,UAAU,0BAA0B,CAAC,IAAyB,EAAE,EAAU;IAC9E,OAAO,KAAK,IAAI,IAAI,EAAE,IAAI,CAAC;AAC7B,CAAC;AAED,sFAAsF;AACtF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GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC5B,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC7B,8FAA8F;IAC9F,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC;CAC3C,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,CAAC,MAAM,CAAC;IACzF,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type RecordReferenceType } from './record-references.js';
|
|
2
|
+
/**
|
|
3
|
+
* The formatted-text grammar of a record's free text — an Opportunity's or a
|
|
4
|
+
* Project's description, a note's or a message's body, a Task's description
|
|
5
|
+
* (`specs/158-crm-opportunity-inline-editing/` research R-2; moved here from
|
|
6
|
+
* `crm-rich-text.ts` under neutral names by `specs/163-projects-and-tasks/`
|
|
7
|
+
* research R-14, which `crm-rich-text.ts` re-exports under its own names).
|
|
8
|
+
*
|
|
9
|
+
* **What is stored is still a string**, carrying the `[[type:id]]` reference
|
|
10
|
+
* tokens it always carried, with a small Markdown subset on top:
|
|
11
|
+
*
|
|
12
|
+
* | Written | Read as |
|
|
13
|
+
* | ------------------ | ---------------------------------------- |
|
|
14
|
+
* | `**text**` | bold |
|
|
15
|
+
* | `_text_` | italic — not inside a word (`ABC_1_X`) |
|
|
16
|
+
* | `~~text~~` | strikethrough |
|
|
17
|
+
* | `[label](https://…)` | a link — `http`, `https`, `mailto` only |
|
|
18
|
+
* | `- item` | a bulleted list's item |
|
|
19
|
+
* | `3. item` | a numbered list's item |
|
|
20
|
+
* | `\*`, `\_`, … | the character itself |
|
|
21
|
+
*
|
|
22
|
+
* Every line is a block. Text written before formatting existed reads as the
|
|
23
|
+
* paragraphs it was, so nothing stored needs migrating; the token grammar, the
|
|
24
|
+
* length limits, mention extraction and search are untouched; and an e-mail or
|
|
25
|
+
* a bell entry that shows the text plainly shows it readably
|
|
26
|
+
* (`recordRichTextToPlain`).
|
|
27
|
+
*
|
|
28
|
+
* **Nothing here is HTML.** A screen draws the blocks as elements of its own,
|
|
29
|
+
* every stretch of text as a text node, so there is no markup to sanitise.
|
|
30
|
+
*/
|
|
31
|
+
export type RecordRichMark = 'bold' | 'italic' | 'strike';
|
|
32
|
+
export type RecordRichInline = {
|
|
33
|
+
kind: 'text';
|
|
34
|
+
text: string;
|
|
35
|
+
marks: RecordRichMark[];
|
|
36
|
+
href?: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'reference';
|
|
39
|
+
type: RecordReferenceType;
|
|
40
|
+
id: string;
|
|
41
|
+
marks: RecordRichMark[];
|
|
42
|
+
};
|
|
43
|
+
export type RecordRichBlock = {
|
|
44
|
+
kind: 'paragraph';
|
|
45
|
+
content: RecordRichInline[];
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'bullet_list';
|
|
48
|
+
items: RecordRichInline[][];
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'ordered_list';
|
|
51
|
+
start: number;
|
|
52
|
+
items: RecordRichInline[][];
|
|
53
|
+
};
|
|
54
|
+
/** Whether `href` may be a link's address. */
|
|
55
|
+
export declare function isSafeRecordRichHref(href: string): boolean;
|
|
56
|
+
/** The blocks a stored text stands for. The empty text is no blocks. */
|
|
57
|
+
export declare function parseRecordRichText(source: string): RecordRichBlock[];
|
|
58
|
+
/** The stored text of `blocks` — the inverse of `parseRecordRichText`. */
|
|
59
|
+
export declare function formatRecordRichText(blocks: readonly RecordRichBlock[]): string;
|
|
60
|
+
/**
|
|
61
|
+
* The text without its formatting, for a place that shows text plainly — an
|
|
62
|
+
* e-mail's text part, a bell entry, a preview. Reference tokens are kept for
|
|
63
|
+
* the caller to resolve; list items keep their markers, links their address.
|
|
64
|
+
*/
|
|
65
|
+
export declare function recordRichTextToPlain(source: string): string;
|
|
66
|
+
//# sourceMappingURL=record-rich-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-rich-text.d.ts","sourceRoot":"","sources":["../src/record-rich-text.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAM1D,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OA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