quickbase-js 2.1.0 → 2.2.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 +674 -90
- package/bin/quickbase-js.js +54 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +5 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/ticket.d.ts +13 -0
- package/dist/auth/ticket.d.ts.map +1 -1
- package/dist/auth/ticket.js +103 -3
- package/dist/auth/ticket.js.map +1 -1
- package/dist/cli/schema.d.ts +23 -0
- package/dist/cli/schema.d.ts.map +1 -0
- package/dist/cli/schema.js +425 -0
- package/dist/cli/schema.js.map +1 -0
- package/dist/client/request.d.ts +2 -1
- package/dist/client/request.d.ts.map +1 -1
- package/dist/client/request.js +165 -18
- package/dist/client/request.js.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +3 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +32 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/schema.d.ts +37 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +168 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/transform.d.ts +36 -0
- package/dist/core/transform.d.ts.map +1 -0
- package/dist/core/transform.js +205 -0
- package/dist/core/transform.js.map +1 -0
- package/dist/core/types.d.ts +87 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/quickbase.esm.js +3 -3
- package/dist/quickbase.esm.js.map +4 -4
- package/dist/quickbase.min.js +3 -3
- package/dist/quickbase.min.js.map +4 -4
- package/dist/xml/codepages.d.ts +60 -0
- package/dist/xml/codepages.d.ts.map +1 -0
- package/dist/xml/codepages.js +88 -0
- package/dist/xml/codepages.js.map +1 -0
- package/dist/xml/dbvars.d.ts +39 -0
- package/dist/xml/dbvars.d.ts.map +1 -0
- package/dist/xml/dbvars.js +54 -0
- package/dist/xml/dbvars.js.map +1 -0
- package/dist/xml/errors.d.ts +64 -0
- package/dist/xml/errors.d.ts.map +1 -0
- package/dist/xml/errors.js +102 -0
- package/dist/xml/errors.js.map +1 -0
- package/dist/xml/fields.d.ts +45 -0
- package/dist/xml/fields.d.ts.map +1 -0
- package/dist/xml/fields.js +86 -0
- package/dist/xml/fields.js.map +1 -0
- package/dist/xml/groups.d.ts +196 -0
- package/dist/xml/groups.d.ts.map +1 -0
- package/dist/xml/groups.js +424 -0
- package/dist/xml/groups.js.map +1 -0
- package/dist/xml/html.d.ts +61 -0
- package/dist/xml/html.d.ts.map +1 -0
- package/dist/xml/html.js +110 -0
- package/dist/xml/html.js.map +1 -0
- package/dist/xml/index.d.ts +453 -0
- package/dist/xml/index.d.ts.map +1 -0
- package/dist/xml/index.js +741 -0
- package/dist/xml/index.js.map +1 -0
- package/dist/xml/metadata.d.ts +49 -0
- package/dist/xml/metadata.d.ts.map +1 -0
- package/dist/xml/metadata.js +84 -0
- package/dist/xml/metadata.js.map +1 -0
- package/dist/xml/records.d.ts +106 -0
- package/dist/xml/records.d.ts.map +1 -0
- package/dist/xml/records.js +220 -0
- package/dist/xml/records.js.map +1 -0
- package/dist/xml/request.d.ts +115 -0
- package/dist/xml/request.d.ts.map +1 -0
- package/dist/xml/request.js +167 -0
- package/dist/xml/request.js.map +1 -0
- package/dist/xml/roles.d.ts +117 -0
- package/dist/xml/roles.d.ts.map +1 -0
- package/dist/xml/roles.js +241 -0
- package/dist/xml/roles.js.map +1 -0
- package/dist/xml/schema.d.ts +94 -0
- package/dist/xml/schema.d.ts.map +1 -0
- package/dist/xml/schema.js +354 -0
- package/dist/xml/schema.js.map +1 -0
- package/dist/xml/transform.d.ts +154 -0
- package/dist/xml/transform.d.ts.map +1 -0
- package/dist/xml/transform.js +182 -0
- package/dist/xml/transform.js.map +1 -0
- package/dist/xml/types.d.ts +531 -0
- package/dist/xml/types.d.ts.map +1 -0
- package/dist/xml/types.js +22 -0
- package/dist/xml/types.js.map +1 -0
- package/dist/xml/users.d.ts +92 -0
- package/dist/xml/users.d.ts.map +1 -0
- package/dist/xml/users.js +166 -0
- package/dist/xml/users.js.map +1 -0
- package/dist/xml/webhooks.d.ts +98 -0
- package/dist/xml/webhooks.d.ts.map +1 -0
- package/dist/xml/webhooks.js +202 -0
- package/dist/xml/webhooks.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Request/Response Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities for building XML requests and parsing XML responses
|
|
5
|
+
* for the legacy QuickBase XML API.
|
|
6
|
+
*
|
|
7
|
+
* XML-API: Remove this file when QuickBase discontinues the XML API.
|
|
8
|
+
* To find all XML API code, search for: XML-API
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Build an XML API request body.
|
|
12
|
+
* Wraps the inner XML content in <qdbapi> tags.
|
|
13
|
+
*
|
|
14
|
+
* @param inner - The inner XML content (without qdbapi wrapper)
|
|
15
|
+
* @returns Complete XML request body
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* buildRequest('<userid>123</userid><roleid>10</roleid>')
|
|
19
|
+
* // Returns: '<qdbapi><userid>123</userid><roleid>10</roleid></qdbapi>'
|
|
20
|
+
*/
|
|
21
|
+
export function buildRequest(inner) {
|
|
22
|
+
return `<qdbapi>${inner}</qdbapi>`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Escape special characters for safe inclusion in XML.
|
|
26
|
+
*
|
|
27
|
+
* @param str - The string to escape
|
|
28
|
+
* @returns XML-escaped string
|
|
29
|
+
*/
|
|
30
|
+
export function escapeXml(str) {
|
|
31
|
+
return str
|
|
32
|
+
.replace(/&/g, '&')
|
|
33
|
+
.replace(/</g, '<')
|
|
34
|
+
.replace(/>/g, '>')
|
|
35
|
+
.replace(/"/g, '"')
|
|
36
|
+
.replace(/'/g, ''');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extract text content from a single XML tag.
|
|
40
|
+
* Uses regex for simple extraction without DOM parsing.
|
|
41
|
+
*
|
|
42
|
+
* @param xml - The XML string to search
|
|
43
|
+
* @param tag - The tag name to extract
|
|
44
|
+
* @returns The text content or empty string if not found
|
|
45
|
+
*/
|
|
46
|
+
export function getTagContent(xml, tag) {
|
|
47
|
+
// Match tag with optional attributes, capture inner content
|
|
48
|
+
const match = xml.match(new RegExp(`<${tag}(?:\\s[^>]*)?>([^<]*)</${tag}>`));
|
|
49
|
+
return match?.[1] ?? '';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Extract text content with CDATA support.
|
|
53
|
+
* Some XML responses wrap content in CDATA blocks.
|
|
54
|
+
*
|
|
55
|
+
* @param xml - The XML string to search
|
|
56
|
+
* @param tag - The tag name to extract
|
|
57
|
+
* @returns The text content or empty string if not found
|
|
58
|
+
*/
|
|
59
|
+
export function getTagContentWithCDATA(xml, tag) {
|
|
60
|
+
// Try CDATA first
|
|
61
|
+
const cdataMatch = xml.match(new RegExp(`<${tag}>\\s*<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>\\s*</${tag}>`));
|
|
62
|
+
if (cdataMatch && cdataMatch[1] !== undefined) {
|
|
63
|
+
return cdataMatch[1];
|
|
64
|
+
}
|
|
65
|
+
// Fall back to regular content
|
|
66
|
+
return getTagContent(xml, tag);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extract an attribute value from an XML element.
|
|
70
|
+
*
|
|
71
|
+
* @param xml - The XML element string
|
|
72
|
+
* @param attr - The attribute name
|
|
73
|
+
* @returns The attribute value or empty string if not found
|
|
74
|
+
*/
|
|
75
|
+
export function getAttribute(xml, attr) {
|
|
76
|
+
const match = xml.match(new RegExp(`${attr}="([^"]*)"`));
|
|
77
|
+
return match?.[1] ?? '';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extract all occurrences of a tag as an array of strings.
|
|
81
|
+
*
|
|
82
|
+
* @param xml - The XML string to search
|
|
83
|
+
* @param tag - The tag name to extract
|
|
84
|
+
* @returns Array of XML element strings (including tags)
|
|
85
|
+
*/
|
|
86
|
+
export function getAllElements(xml, tag) {
|
|
87
|
+
const regex = new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, 'g');
|
|
88
|
+
const elements = [];
|
|
89
|
+
let match;
|
|
90
|
+
while ((match = regex.exec(xml)) !== null) {
|
|
91
|
+
elements.push(match[0]);
|
|
92
|
+
}
|
|
93
|
+
return elements;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Parse the base response fields from an XML API response.
|
|
97
|
+
*
|
|
98
|
+
* @param xml - The XML response string
|
|
99
|
+
* @returns BaseResponse with action, errcode, errtext, errdetail
|
|
100
|
+
*/
|
|
101
|
+
export function parseBaseResponse(xml) {
|
|
102
|
+
const errdetail = getTagContent(xml, 'errdetail');
|
|
103
|
+
return {
|
|
104
|
+
action: getTagContent(xml, 'action'),
|
|
105
|
+
errcode: parseInt(getTagContent(xml, 'errcode'), 10) || 0,
|
|
106
|
+
errtext: getTagContent(xml, 'errtext'),
|
|
107
|
+
errdetail: errdetail || undefined,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create an XML element with content.
|
|
112
|
+
* Escapes the content automatically.
|
|
113
|
+
*
|
|
114
|
+
* @param tag - The tag name
|
|
115
|
+
* @param content - The content (will be escaped)
|
|
116
|
+
* @returns XML element string
|
|
117
|
+
*/
|
|
118
|
+
export function xmlElement(tag, content) {
|
|
119
|
+
return `<${tag}>${escapeXml(String(content))}</${tag}>`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create an XML element with CDATA content.
|
|
123
|
+
* Use for large text content that may contain special characters.
|
|
124
|
+
*
|
|
125
|
+
* @param tag - The tag name
|
|
126
|
+
* @param content - The content (will be wrapped in CDATA)
|
|
127
|
+
* @returns XML element string with CDATA
|
|
128
|
+
*/
|
|
129
|
+
export function xmlElementCDATA(tag, content) {
|
|
130
|
+
// CDATA cannot contain the sequence ]]> - if present, split it
|
|
131
|
+
const escaped = content.replace(/\]\]>/g, ']]]]><![CDATA[>');
|
|
132
|
+
return `<${tag}><![CDATA[${escaped}]]></${tag}>`;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Create an XML element with an attribute.
|
|
136
|
+
*
|
|
137
|
+
* @param tag - The tag name
|
|
138
|
+
* @param attrName - The attribute name
|
|
139
|
+
* @param attrValue - The attribute value
|
|
140
|
+
* @param content - The content (will be escaped)
|
|
141
|
+
* @returns XML element string with attribute
|
|
142
|
+
*/
|
|
143
|
+
export function xmlElementWithAttr(tag, attrName, attrValue, content) {
|
|
144
|
+
return `<${tag} ${attrName}="${escapeXml(String(attrValue))}">${escapeXml(String(content))}</${tag}>`;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Parse a boolean-like value from XML.
|
|
148
|
+
* QuickBase uses "1" for true, "0" or empty for false.
|
|
149
|
+
*
|
|
150
|
+
* @param value - The string value to parse
|
|
151
|
+
* @returns boolean
|
|
152
|
+
*/
|
|
153
|
+
export function parseXmlBool(value) {
|
|
154
|
+
return value === '1' || value.toLowerCase() === 'true';
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Parse a numeric value from XML.
|
|
158
|
+
*
|
|
159
|
+
* @param value - The string value to parse
|
|
160
|
+
* @param defaultValue - Default value if parsing fails
|
|
161
|
+
* @returns number
|
|
162
|
+
*/
|
|
163
|
+
export function parseXmlNumber(value, defaultValue = 0) {
|
|
164
|
+
const num = parseInt(value, 10);
|
|
165
|
+
return isNaN(num) ? defaultValue : num;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/xml/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,WAAW,KAAK,WAAW,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,GAAW;IACpD,4DAA4D;IAC5D,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,0BAA0B,GAAG,GAAG,CAAC,CAAC,CAAC;IAC7E,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW,EAAE,GAAW;IAC7D,kBAAkB;IAClB,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAC1B,IAAI,MAAM,CAAC,IAAI,GAAG,8CAA8C,GAAG,GAAG,CAAC,CACxE,CAAC;IACF,IAAI,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IACD,+BAA+B;IAC/B,OAAO,aAAa,CAA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AM,CAAC,OAAO,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC;AAC1D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAAe;IAC1D,+DAA+D;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC7D,OAAO,IAAI,GAAG,aAAa,OAAO,QAAQ,GAAG,GAAG,CAAC;AACnD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAW,EACX,QAAgB,EAChB,SAA0B,EAC1B,OAAwB;IAExB,OAAO,IAAI,GAAG,IAAI,QAAQ,KAAK,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC;AACxG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,YAAY,GAAG,CAAC;IAC5D,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Role Management
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing roles and user role assignments.
|
|
5
|
+
*
|
|
6
|
+
* XML-API: Remove this file when QuickBase discontinues the XML API.
|
|
7
|
+
* To find all XML API code, search for: XML-API
|
|
8
|
+
*/
|
|
9
|
+
import type { XmlCaller, GetRoleInfoResult, UserRolesResult, GetUserRoleResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get all roles defined in an application.
|
|
12
|
+
*
|
|
13
|
+
* @see https://help.quickbase.com/docs/api-getroleinfo
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const result = await getRoleInfo(caller, 'bqxyz123');
|
|
18
|
+
* for (const role of result.roles) {
|
|
19
|
+
* console.log(`Role ${role.id}: ${role.name} (${role.access.description})`);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function getRoleInfo(caller: XmlCaller, appId: string): Promise<GetRoleInfoResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Get all users in an application and their role assignments.
|
|
26
|
+
*
|
|
27
|
+
* Requires Basic Access with Sharing or Full Administration access.
|
|
28
|
+
*
|
|
29
|
+
* @see https://help.quickbase.com/docs/api-userroles
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const result = await userRoles(caller, 'bqxyz123');
|
|
34
|
+
* for (const user of result.users) {
|
|
35
|
+
* console.log(`${user.name}: ${user.roles.map(r => r.name).join(', ')}`);
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function userRoles(caller: XmlCaller, appId: string): Promise<UserRolesResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Get roles for a specific user.
|
|
42
|
+
*
|
|
43
|
+
* If userId is omitted, returns your own roles.
|
|
44
|
+
* Set includeGroups to true to include roles assigned via groups.
|
|
45
|
+
*
|
|
46
|
+
* @see https://help.quickbase.com/docs/api-getuserrole
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const result = await getUserRole(caller, 'bqxyz123', '112149.bhsv', true);
|
|
51
|
+
* console.log(`User: ${result.userName}`);
|
|
52
|
+
* for (const role of result.roles) {
|
|
53
|
+
* if (role.member) {
|
|
54
|
+
* console.log(` ${role.name} (via ${role.member.type}: ${role.member.name})`);
|
|
55
|
+
* } else {
|
|
56
|
+
* console.log(` ${role.name}`);
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function getUserRole(caller: XmlCaller, appId: string, userId?: string, includeGroups?: boolean): Promise<GetUserRoleResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Assign a user to a role.
|
|
64
|
+
*
|
|
65
|
+
* You can call this multiple times to give a user multiple roles.
|
|
66
|
+
* After assigning, use sendInvitation to invite the user.
|
|
67
|
+
*
|
|
68
|
+
* Requires Basic Access with Sharing or Full Administration access.
|
|
69
|
+
* Users with Basic Access cannot add users to admin roles.
|
|
70
|
+
*
|
|
71
|
+
* @see https://help.quickbase.com/docs/api-addusertorole
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* await addUserToRole(caller, 'bqxyz123', '112149.bhsv', 10);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function addUserToRole(caller: XmlCaller, appId: string, userId: string, roleId: number): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Remove a user from a specific role.
|
|
81
|
+
*
|
|
82
|
+
* If this is the user's only role, they lose all access to the app
|
|
83
|
+
* and are removed from the app's user list.
|
|
84
|
+
*
|
|
85
|
+
* To temporarily disable access while keeping the user in the app,
|
|
86
|
+
* use changeUserRole with newRoleId=0 instead.
|
|
87
|
+
*
|
|
88
|
+
* @see https://help.quickbase.com/docs/api-removeuserfromrole
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* await removeUserFromRole(caller, 'bqxyz123', '112149.bhsv', 10);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function removeUserFromRole(caller: XmlCaller, appId: string, userId: string, roleId: number): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Change a user's role or disable their access.
|
|
98
|
+
*
|
|
99
|
+
* This is preferred over removeUserFromRole when you want to keep the
|
|
100
|
+
* user in the app's user list but change/disable their access.
|
|
101
|
+
*
|
|
102
|
+
* Pass newRoleId=0 (or omit it) to set the role to "None" (role ID 9),
|
|
103
|
+
* which disables access while keeping the user on the app's user list.
|
|
104
|
+
*
|
|
105
|
+
* @see https://help.quickbase.com/docs/api-changeuserrole
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* // Change from role 10 to role 11
|
|
110
|
+
* await changeUserRole(caller, 'bqxyz123', '112149.bhsv', 10, 11);
|
|
111
|
+
*
|
|
112
|
+
* // Disable access (set to None role)
|
|
113
|
+
* await changeUserRole(caller, 'bqxyz123', '112149.bhsv', 10, 0);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function changeUserRole(caller: XmlCaller, appId: string, userId: string, currentRoleId: number, newRoleId?: number): Promise<void>;
|
|
117
|
+
//# sourceMappingURL=roles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/xml/roles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EAMT,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAwEpB;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAY5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAY1B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAiC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Role Management
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing roles and user role assignments.
|
|
5
|
+
*
|
|
6
|
+
* XML-API: Remove this file when QuickBase discontinues the XML API.
|
|
7
|
+
* To find all XML API code, search for: XML-API
|
|
8
|
+
*/
|
|
9
|
+
import { checkError } from './errors.js';
|
|
10
|
+
import { buildRequest, escapeXml, parseBaseResponse, getTagContent, getAttribute, getAllElements, parseXmlNumber, } from './request.js';
|
|
11
|
+
/**
|
|
12
|
+
* Parse a single role element from XML
|
|
13
|
+
*/
|
|
14
|
+
function parseRole(roleXml) {
|
|
15
|
+
const id = parseXmlNumber(getAttribute(roleXml, 'id'));
|
|
16
|
+
const name = getTagContent(roleXml, 'name');
|
|
17
|
+
// Parse access element
|
|
18
|
+
const accessMatch = roleXml.match(/<access[^>]*id="(\d+)"[^>]*>([^<]*)<\/access>/);
|
|
19
|
+
const access = {
|
|
20
|
+
id: accessMatch ? parseXmlNumber(accessMatch[1] ?? '0') : 0,
|
|
21
|
+
description: accessMatch?.[2] ?? '',
|
|
22
|
+
};
|
|
23
|
+
return { id, name, access };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse a role with member info (from GetUserRole with inclgrps)
|
|
27
|
+
*/
|
|
28
|
+
function parseUserRole(roleXml) {
|
|
29
|
+
const role = parseRole(roleXml);
|
|
30
|
+
// Parse member element if present
|
|
31
|
+
const memberMatch = roleXml.match(/<member[^>]*type="([^"]*)"[^>]*>([^<]*)<\/member>/);
|
|
32
|
+
const member = memberMatch && memberMatch[1] && memberMatch[2]
|
|
33
|
+
? { type: memberMatch[1], name: memberMatch[2] }
|
|
34
|
+
: undefined;
|
|
35
|
+
return { ...role, member };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse a user with roles from UserRoles response
|
|
39
|
+
*/
|
|
40
|
+
function parseUserWithRoles(userXml) {
|
|
41
|
+
const id = getAttribute(userXml, 'id');
|
|
42
|
+
const type = getAttribute(userXml, 'type') || 'user';
|
|
43
|
+
const name = getTagContent(userXml, 'name');
|
|
44
|
+
const firstName = getTagContent(userXml, 'firstName') || undefined;
|
|
45
|
+
const lastName = getTagContent(userXml, 'lastName') || undefined;
|
|
46
|
+
const lastAccess = getTagContent(userXml, 'lastAccess') || undefined;
|
|
47
|
+
const lastAccessAppLocal = getTagContent(userXml, 'lastAccessAppLocal') || undefined;
|
|
48
|
+
// Parse roles
|
|
49
|
+
const roleElements = getAllElements(userXml, 'role');
|
|
50
|
+
const roles = roleElements.map(parseRole);
|
|
51
|
+
return {
|
|
52
|
+
id,
|
|
53
|
+
type,
|
|
54
|
+
name,
|
|
55
|
+
firstName,
|
|
56
|
+
lastName,
|
|
57
|
+
lastAccess,
|
|
58
|
+
lastAccessAppLocal,
|
|
59
|
+
roles,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get all roles defined in an application.
|
|
64
|
+
*
|
|
65
|
+
* @see https://help.quickbase.com/docs/api-getroleinfo
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const result = await getRoleInfo(caller, 'bqxyz123');
|
|
70
|
+
* for (const role of result.roles) {
|
|
71
|
+
* console.log(`Role ${role.id}: ${role.name} (${role.access.description})`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export async function getRoleInfo(caller, appId) {
|
|
76
|
+
const body = buildRequest('');
|
|
77
|
+
const xml = await caller.doXml(appId, 'API_GetRoleInfo', body);
|
|
78
|
+
const base = parseBaseResponse(xml);
|
|
79
|
+
checkError(base);
|
|
80
|
+
// Parse roles
|
|
81
|
+
const roleElements = getAllElements(xml, 'role');
|
|
82
|
+
const roles = roleElements.map(parseRole);
|
|
83
|
+
return { roles };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get all users in an application and their role assignments.
|
|
87
|
+
*
|
|
88
|
+
* Requires Basic Access with Sharing or Full Administration access.
|
|
89
|
+
*
|
|
90
|
+
* @see https://help.quickbase.com/docs/api-userroles
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const result = await userRoles(caller, 'bqxyz123');
|
|
95
|
+
* for (const user of result.users) {
|
|
96
|
+
* console.log(`${user.name}: ${user.roles.map(r => r.name).join(', ')}`);
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export async function userRoles(caller, appId) {
|
|
101
|
+
const body = buildRequest('');
|
|
102
|
+
const xml = await caller.doXml(appId, 'API_UserRoles', body);
|
|
103
|
+
const base = parseBaseResponse(xml);
|
|
104
|
+
checkError(base);
|
|
105
|
+
// Parse users
|
|
106
|
+
const userElements = getAllElements(xml, 'user');
|
|
107
|
+
const users = userElements.map(parseUserWithRoles);
|
|
108
|
+
return { users };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get roles for a specific user.
|
|
112
|
+
*
|
|
113
|
+
* If userId is omitted, returns your own roles.
|
|
114
|
+
* Set includeGroups to true to include roles assigned via groups.
|
|
115
|
+
*
|
|
116
|
+
* @see https://help.quickbase.com/docs/api-getuserrole
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const result = await getUserRole(caller, 'bqxyz123', '112149.bhsv', true);
|
|
121
|
+
* console.log(`User: ${result.userName}`);
|
|
122
|
+
* for (const role of result.roles) {
|
|
123
|
+
* if (role.member) {
|
|
124
|
+
* console.log(` ${role.name} (via ${role.member.type}: ${role.member.name})`);
|
|
125
|
+
* } else {
|
|
126
|
+
* console.log(` ${role.name}`);
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export async function getUserRole(caller, appId, userId, includeGroups) {
|
|
132
|
+
let inner = '';
|
|
133
|
+
if (userId) {
|
|
134
|
+
inner += `<userid>${escapeXml(userId)}</userid>`;
|
|
135
|
+
}
|
|
136
|
+
if (includeGroups) {
|
|
137
|
+
inner += '<inclgrps>1</inclgrps>';
|
|
138
|
+
}
|
|
139
|
+
const body = buildRequest(inner);
|
|
140
|
+
const xml = await caller.doXml(appId, 'API_GetUserRole', body);
|
|
141
|
+
const base = parseBaseResponse(xml);
|
|
142
|
+
checkError(base);
|
|
143
|
+
// Parse user element
|
|
144
|
+
const userMatch = xml.match(/<user[^>]*id="([^"]*)"[^>]*>([\s\S]*?)<\/user>/);
|
|
145
|
+
if (!userMatch || !userMatch[1]) {
|
|
146
|
+
throw new Error('Invalid API_GetUserRole response: no user element');
|
|
147
|
+
}
|
|
148
|
+
const userIdResult = userMatch[1];
|
|
149
|
+
const userXml = userMatch[0];
|
|
150
|
+
const userName = getTagContent(userXml, 'name');
|
|
151
|
+
// Parse roles (with member info if inclgrps was used)
|
|
152
|
+
const roleElements = getAllElements(userXml, 'role');
|
|
153
|
+
const roles = roleElements.map(parseUserRole);
|
|
154
|
+
return {
|
|
155
|
+
userId: userIdResult,
|
|
156
|
+
userName,
|
|
157
|
+
roles,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Assign a user to a role.
|
|
162
|
+
*
|
|
163
|
+
* You can call this multiple times to give a user multiple roles.
|
|
164
|
+
* After assigning, use sendInvitation to invite the user.
|
|
165
|
+
*
|
|
166
|
+
* Requires Basic Access with Sharing or Full Administration access.
|
|
167
|
+
* Users with Basic Access cannot add users to admin roles.
|
|
168
|
+
*
|
|
169
|
+
* @see https://help.quickbase.com/docs/api-addusertorole
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* await addUserToRole(caller, 'bqxyz123', '112149.bhsv', 10);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export async function addUserToRole(caller, appId, userId, roleId) {
|
|
177
|
+
const inner = `<userid>${escapeXml(userId)}</userid>` +
|
|
178
|
+
`<roleid>${roleId}</roleid>`;
|
|
179
|
+
const body = buildRequest(inner);
|
|
180
|
+
const xml = await caller.doXml(appId, 'API_AddUserToRole', body);
|
|
181
|
+
const base = parseBaseResponse(xml);
|
|
182
|
+
checkError(base);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Remove a user from a specific role.
|
|
186
|
+
*
|
|
187
|
+
* If this is the user's only role, they lose all access to the app
|
|
188
|
+
* and are removed from the app's user list.
|
|
189
|
+
*
|
|
190
|
+
* To temporarily disable access while keeping the user in the app,
|
|
191
|
+
* use changeUserRole with newRoleId=0 instead.
|
|
192
|
+
*
|
|
193
|
+
* @see https://help.quickbase.com/docs/api-removeuserfromrole
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* await removeUserFromRole(caller, 'bqxyz123', '112149.bhsv', 10);
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export async function removeUserFromRole(caller, appId, userId, roleId) {
|
|
201
|
+
const inner = `<userid>${escapeXml(userId)}</userid>` +
|
|
202
|
+
`<roleid>${roleId}</roleid>`;
|
|
203
|
+
const body = buildRequest(inner);
|
|
204
|
+
const xml = await caller.doXml(appId, 'API_RemoveUserFromRole', body);
|
|
205
|
+
const base = parseBaseResponse(xml);
|
|
206
|
+
checkError(base);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Change a user's role or disable their access.
|
|
210
|
+
*
|
|
211
|
+
* This is preferred over removeUserFromRole when you want to keep the
|
|
212
|
+
* user in the app's user list but change/disable their access.
|
|
213
|
+
*
|
|
214
|
+
* Pass newRoleId=0 (or omit it) to set the role to "None" (role ID 9),
|
|
215
|
+
* which disables access while keeping the user on the app's user list.
|
|
216
|
+
*
|
|
217
|
+
* @see https://help.quickbase.com/docs/api-changeuserrole
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* // Change from role 10 to role 11
|
|
222
|
+
* await changeUserRole(caller, 'bqxyz123', '112149.bhsv', 10, 11);
|
|
223
|
+
*
|
|
224
|
+
* // Disable access (set to None role)
|
|
225
|
+
* await changeUserRole(caller, 'bqxyz123', '112149.bhsv', 10, 0);
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export async function changeUserRole(caller, appId, userId, currentRoleId, newRoleId) {
|
|
229
|
+
let inner = `<userid>${escapeXml(userId)}</userid>` +
|
|
230
|
+
`<roleid>${currentRoleId}</roleid>`;
|
|
231
|
+
// If newRoleId is provided and > 0, include it
|
|
232
|
+
// If omitted or 0, QuickBase sets role to None (9)
|
|
233
|
+
if (newRoleId !== undefined && newRoleId > 0) {
|
|
234
|
+
inner += `<newRoleid>${newRoleId}</newRoleid>`;
|
|
235
|
+
}
|
|
236
|
+
const body = buildRequest(inner);
|
|
237
|
+
const xml = await caller.doXml(appId, 'API_ChangeUserRole', body);
|
|
238
|
+
const base = parseBaseResponse(xml);
|
|
239
|
+
checkError(base);
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/xml/roles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,SAAS,SAAS,CAAC,OAAe;IAChC,MAAM,EAAE,GAAG,cAAc,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAE5C,uBAAuB;IACvB,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnF,MAAM,MAAM,GAAe;QACzB,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;KACpC,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAEhC,kCAAkC;IAClC,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvF,MAAM,MAAM,GAA2B,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC;QACpF,CAAC,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
+
*
|
|
4
|
+
* Endpoints for discovering apps/tables and getting schema information.
|
|
5
|
+
*
|
|
6
|
+
* XML-API: Remove this file when QuickBase discontinues the XML API.
|
|
7
|
+
* To find all XML API code, search for: XML-API
|
|
8
|
+
*/
|
|
9
|
+
import type { XmlCaller, DBInfo, GetSchemaResult, GrantedDBsResult, FindDBByNameResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* List all apps/tables the user can access.
|
|
12
|
+
*
|
|
13
|
+
* Returns apps across all domains by default. Use realmAppsOnly to limit
|
|
14
|
+
* to the current realm.
|
|
15
|
+
*
|
|
16
|
+
* @see https://help.quickbase.com/docs/api-granteddbs
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const result = await grantedDBs(caller, { parentsOnly: true });
|
|
21
|
+
* for (const db of result.databases) {
|
|
22
|
+
* console.log(`${db.name} (${db.dbid})`);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function grantedDBs(caller: XmlCaller, options?: {
|
|
27
|
+
parentsOnly?: boolean;
|
|
28
|
+
excludeParents?: boolean;
|
|
29
|
+
adminOnly?: boolean;
|
|
30
|
+
includeAncestors?: boolean;
|
|
31
|
+
withEmbeddedTables?: boolean;
|
|
32
|
+
realmAppsOnly?: boolean;
|
|
33
|
+
}): Promise<GrantedDBsResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Find an app by name.
|
|
36
|
+
*
|
|
37
|
+
* Searches only apps you have access to. May return multiple results
|
|
38
|
+
* if multiple apps share the same name.
|
|
39
|
+
*
|
|
40
|
+
* @see https://help.quickbase.com/docs/api-finddbbyname
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const result = await findDBByName(caller, 'My App', true);
|
|
45
|
+
* console.log(`Found app: ${result.dbid}`);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function findDBByName(caller: XmlCaller, name: string, parentsOnly?: boolean): Promise<FindDBByNameResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Get app/table metadata.
|
|
51
|
+
*
|
|
52
|
+
* Returns information like last modified time, record count, manager info.
|
|
53
|
+
*
|
|
54
|
+
* @see https://help.quickbase.com/docs/api-getdbinfo
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const info = await getDBInfo(caller, 'bqxyz123');
|
|
59
|
+
* console.log(`${info.name}: ${info.numRecords} records`);
|
|
60
|
+
* console.log(`Manager: ${info.managerName}`);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function getDBInfo(caller: XmlCaller, dbid: string): Promise<DBInfo>;
|
|
64
|
+
/**
|
|
65
|
+
* Get total record count for a table.
|
|
66
|
+
*
|
|
67
|
+
* @see https://help.quickbase.com/docs/api-getnumrecords
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const count = await getNumRecords(caller, 'bqtable123');
|
|
72
|
+
* console.log(`Table has ${count} records`);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function getNumRecords(caller: XmlCaller, tableId: string): Promise<number>;
|
|
76
|
+
/**
|
|
77
|
+
* Get comprehensive app/table schema information.
|
|
78
|
+
*
|
|
79
|
+
* When called on an app dbid: returns DBVars and child table dbids.
|
|
80
|
+
* When called on a table dbid: returns fields, queries, DBVars, and more.
|
|
81
|
+
*
|
|
82
|
+
* @see https://help.quickbase.com/docs/api-getschema
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const schema = await getSchema(caller, 'bqtable123');
|
|
87
|
+
* console.log(`Table: ${schema.table.name}`);
|
|
88
|
+
* for (const field of schema.table.fields ?? []) {
|
|
89
|
+
* console.log(` Field ${field.id}: ${field.label} (${field.fieldType})`);
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function getSchema(caller: XmlCaller, dbid: string): Promise<GetSchemaResult>;
|
|
94
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/xml/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EAET,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAOnB,MAAM,YAAY,CAAC;AAapB;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,gBAAgB,CAAC,CAiD3B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAkB7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAQjB;AAgHD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC,CA8F1B"}
|