quickbase-js 2.0.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 +804 -59
- package/bin/quickbase-js.js +54 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +9 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/ticket.d.ts +84 -0
- package/dist/auth/ticket.d.ts.map +1 -0
- package/dist/auth/ticket.js +260 -0
- package/dist/auth/ticket.js.map +1 -0
- 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 +12 -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 +3 -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 +104 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +14 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/quickbase.esm.js +6 -2
- package/dist/quickbase.esm.js.map +4 -4
- package/dist/quickbase.min.js +6 -2
- 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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Code Pages
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing stored code pages (HTML, XSL, etc.).
|
|
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, PageType, AddReplaceDBPageResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get stored code page content.
|
|
12
|
+
*
|
|
13
|
+
* Returns the raw page content (HTML, XSL, etc.).
|
|
14
|
+
*
|
|
15
|
+
* @see https://help.quickbase.com/docs/api-getdbpage
|
|
16
|
+
*
|
|
17
|
+
* @param pageIdOrName - Page ID (number) or page name (string)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // By page ID
|
|
22
|
+
* const content = await getDBPage(caller, 'bqapp123', 3);
|
|
23
|
+
*
|
|
24
|
+
* // By page name
|
|
25
|
+
* const content = await getDBPage(caller, 'bqapp123', 'mystylesheet.xsl');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDBPage(caller: XmlCaller, appId: string, pageIdOrName: string | number): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Create or update a code page.
|
|
31
|
+
*
|
|
32
|
+
* Page types:
|
|
33
|
+
* - 1: XSL stylesheets or HTML pages
|
|
34
|
+
* - 3: Exact Forms (Word templates)
|
|
35
|
+
*
|
|
36
|
+
* @see https://help.quickbase.com/docs/api-addreplacedbpage
|
|
37
|
+
*
|
|
38
|
+
* @param pageId - Existing page ID to replace (undefined to create new)
|
|
39
|
+
* @param pageName - Name for the page (required when creating new)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Create a new page
|
|
44
|
+
* const result = await addReplaceDBPage(
|
|
45
|
+
* caller, 'bqapp123',
|
|
46
|
+
* 'mypage.html', undefined, 1,
|
|
47
|
+
* '<html><body>Hello World</body></html>'
|
|
48
|
+
* );
|
|
49
|
+
* console.log(`Created page ID: ${result.pageId}`);
|
|
50
|
+
*
|
|
51
|
+
* // Update existing page
|
|
52
|
+
* await addReplaceDBPage(
|
|
53
|
+
* caller, 'bqapp123',
|
|
54
|
+
* 'mypage.html', 6, 1,
|
|
55
|
+
* '<html><body>Updated content</body></html>'
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function addReplaceDBPage(caller: XmlCaller, appId: string, pageName: string, pageId: number | undefined, pageType: PageType, pageBody: string): Promise<AddReplaceDBPageResult>;
|
|
60
|
+
//# sourceMappingURL=codepages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codepages.d.ts","sourceRoot":"","sources":["../../src/xml/codepages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAWpB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GAAG,MAAM,GAC5B,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,sBAAsB,CAAC,CAkBjC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Code Pages
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing stored code pages (HTML, XSL, etc.).
|
|
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, xmlElementCDATA, parseXmlNumber, } from './request.js';
|
|
11
|
+
/**
|
|
12
|
+
* Get stored code page content.
|
|
13
|
+
*
|
|
14
|
+
* Returns the raw page content (HTML, XSL, etc.).
|
|
15
|
+
*
|
|
16
|
+
* @see https://help.quickbase.com/docs/api-getdbpage
|
|
17
|
+
*
|
|
18
|
+
* @param pageIdOrName - Page ID (number) or page name (string)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // By page ID
|
|
23
|
+
* const content = await getDBPage(caller, 'bqapp123', 3);
|
|
24
|
+
*
|
|
25
|
+
* // By page name
|
|
26
|
+
* const content = await getDBPage(caller, 'bqapp123', 'mystylesheet.xsl');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export async function getDBPage(caller, appId, pageIdOrName) {
|
|
30
|
+
const inner = `<pageID>${escapeXml(String(pageIdOrName))}</pageID>`;
|
|
31
|
+
const body = buildRequest(inner);
|
|
32
|
+
const xml = await caller.doXml(appId, 'API_GetDBPage', body);
|
|
33
|
+
// Note: GetDBPage returns raw HTML, not XML
|
|
34
|
+
// Check if it's an error response
|
|
35
|
+
if (xml.includes('<errcode>') && !xml.includes('<errcode>0</errcode>')) {
|
|
36
|
+
const base = parseBaseResponse(xml);
|
|
37
|
+
checkError(base);
|
|
38
|
+
}
|
|
39
|
+
// If not an error, return the raw content
|
|
40
|
+
// The response is the page content itself, not wrapped in XML
|
|
41
|
+
return xml;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create or update a code page.
|
|
45
|
+
*
|
|
46
|
+
* Page types:
|
|
47
|
+
* - 1: XSL stylesheets or HTML pages
|
|
48
|
+
* - 3: Exact Forms (Word templates)
|
|
49
|
+
*
|
|
50
|
+
* @see https://help.quickbase.com/docs/api-addreplacedbpage
|
|
51
|
+
*
|
|
52
|
+
* @param pageId - Existing page ID to replace (undefined to create new)
|
|
53
|
+
* @param pageName - Name for the page (required when creating new)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Create a new page
|
|
58
|
+
* const result = await addReplaceDBPage(
|
|
59
|
+
* caller, 'bqapp123',
|
|
60
|
+
* 'mypage.html', undefined, 1,
|
|
61
|
+
* '<html><body>Hello World</body></html>'
|
|
62
|
+
* );
|
|
63
|
+
* console.log(`Created page ID: ${result.pageId}`);
|
|
64
|
+
*
|
|
65
|
+
* // Update existing page
|
|
66
|
+
* await addReplaceDBPage(
|
|
67
|
+
* caller, 'bqapp123',
|
|
68
|
+
* 'mypage.html', 6, 1,
|
|
69
|
+
* '<html><body>Updated content</body></html>'
|
|
70
|
+
* );
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export async function addReplaceDBPage(caller, appId, pageName, pageId, pageType, pageBody) {
|
|
74
|
+
let inner = '';
|
|
75
|
+
if (pageId !== undefined) {
|
|
76
|
+
inner += `<pageid>${pageId}</pageid>`;
|
|
77
|
+
}
|
|
78
|
+
inner += `<pagename>${escapeXml(pageName)}</pagename>`;
|
|
79
|
+
inner += `<pagetype>${pageType}</pagetype>`;
|
|
80
|
+
inner += xmlElementCDATA('pagebody', pageBody);
|
|
81
|
+
const body = buildRequest(inner);
|
|
82
|
+
const xml = await caller.doXml(appId, 'API_AddReplaceDBPage', body);
|
|
83
|
+
const base = parseBaseResponse(xml);
|
|
84
|
+
checkError(base);
|
|
85
|
+
const resultPageId = parseXmlNumber(getTagContent(xml, 'pageID'));
|
|
86
|
+
return { pageId: resultPageId };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=codepages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codepages.js","sourceRoot":"","sources":["../../src/xml/codepages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAiB,EACjB,KAAa,EACb,YAA6B;IAE7B,MAAM,KAAK,GAAG,WAAW,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC;IACpE,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;IAE7D,4CAA4C;IAC5C,kCAAkC;IAClC,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACpC,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,0CAA0C;IAC1C,8DAA8D;IAC9D,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAiB,EACjB,KAAa,EACb,QAAgB,EAChB,MAA0B,EAC1B,QAAkB,EAClB,QAAgB;IAEhB,IAAI,KAAK,GAAG,EAAE,CAAC;IAEf,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,IAAI,WAAW,MAAM,WAAW,CAAC;IACxC,CAAC;IACD,KAAK,IAAI,aAAa,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC;IACvD,KAAK,IAAI,aAAa,QAAQ,aAAa,CAAC;IAC5C,KAAK,IAAI,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC;IAEpE,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjB,MAAM,YAAY,GAAG,cAAc,CAAC,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IAClE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Application Variables (DBVars)
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing application variables.
|
|
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 } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get an application variable value.
|
|
12
|
+
*
|
|
13
|
+
* DBVars are application-level variables that can be used in formulas
|
|
14
|
+
* and code pages.
|
|
15
|
+
*
|
|
16
|
+
* @see https://help.quickbase.com/docs/api-getdbvar
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const value = await getDBVar(caller, 'bqapp123', 'myVariable');
|
|
21
|
+
* console.log(`Variable value: ${value}`);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDBVar(caller: XmlCaller, appId: string, varName: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Set an application variable value.
|
|
27
|
+
*
|
|
28
|
+
* Creates the variable if it doesn't exist, or overwrites if it does.
|
|
29
|
+
* Requires Full Administration rights on the application.
|
|
30
|
+
*
|
|
31
|
+
* @see https://help.quickbase.com/docs/api-setdbvar
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* await setDBVar(caller, 'bqapp123', 'myVariable', '42');
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function setDBVar(caller: XmlCaller, appId: string, varName: string, value: string): Promise<void>;
|
|
39
|
+
//# sourceMappingURL=dbvars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbvars.d.ts","sourceRoot":"","sources":["../../src/xml/dbvars.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAS5C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CASjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Application Variables (DBVars)
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing application variables.
|
|
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, } from './request.js';
|
|
11
|
+
/**
|
|
12
|
+
* Get an application variable value.
|
|
13
|
+
*
|
|
14
|
+
* DBVars are application-level variables that can be used in formulas
|
|
15
|
+
* and code pages.
|
|
16
|
+
*
|
|
17
|
+
* @see https://help.quickbase.com/docs/api-getdbvar
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const value = await getDBVar(caller, 'bqapp123', 'myVariable');
|
|
22
|
+
* console.log(`Variable value: ${value}`);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export async function getDBVar(caller, appId, varName) {
|
|
26
|
+
const inner = `<varname>${escapeXml(varName)}</varname>`;
|
|
27
|
+
const body = buildRequest(inner);
|
|
28
|
+
const xml = await caller.doXml(appId, 'API_GetDBVar', body);
|
|
29
|
+
const base = parseBaseResponse(xml);
|
|
30
|
+
checkError(base);
|
|
31
|
+
return getTagContent(xml, 'value');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set an application variable value.
|
|
35
|
+
*
|
|
36
|
+
* Creates the variable if it doesn't exist, or overwrites if it does.
|
|
37
|
+
* Requires Full Administration rights on the application.
|
|
38
|
+
*
|
|
39
|
+
* @see https://help.quickbase.com/docs/api-setdbvar
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* await setDBVar(caller, 'bqapp123', 'myVariable', '42');
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export async function setDBVar(caller, appId, varName, value) {
|
|
47
|
+
const inner = `<varname>${escapeXml(varName)}</varname>` +
|
|
48
|
+
`<value>${escapeXml(value)}</value>`;
|
|
49
|
+
const body = buildRequest(inner);
|
|
50
|
+
const xml = await caller.doXml(appId, 'API_SetDBVar', body);
|
|
51
|
+
const base = parseBaseResponse(xml);
|
|
52
|
+
checkError(base);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=dbvars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbvars.js","sourceRoot":"","sources":["../../src/xml/dbvars.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAiB,EACjB,KAAa,EACb,OAAe;IAEf,MAAM,KAAK,GAAG,YAAY,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC;IACzD,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAE5D,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAiB,EACjB,KAAa,EACb,OAAe,EACf,KAAa;IAEb,MAAM,KAAK,GACT,YAAY,SAAS,CAAC,OAAO,CAAC,YAAY;QAC1C,UAAU,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;IACvC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAE5D,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Errors
|
|
3
|
+
*
|
|
4
|
+
* Error handling for the legacy QuickBase XML API.
|
|
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 { BaseResponse } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Common QuickBase XML API error codes
|
|
12
|
+
*/
|
|
13
|
+
export declare const XmlErrorCode: {
|
|
14
|
+
/** No error (success) */
|
|
15
|
+
readonly Success: 0;
|
|
16
|
+
/** User is not authorized for this action */
|
|
17
|
+
readonly Unauthorized: 4;
|
|
18
|
+
/** Invalid input parameters */
|
|
19
|
+
readonly InvalidInput: 5;
|
|
20
|
+
/** Database/table does not exist */
|
|
21
|
+
readonly NoSuchDatabase: 6;
|
|
22
|
+
/** Access to the resource is denied */
|
|
23
|
+
readonly AccessDenied: 7;
|
|
24
|
+
/** Authentication ticket is invalid or expired */
|
|
25
|
+
readonly InvalidTicket: 8;
|
|
26
|
+
/** Record does not exist */
|
|
27
|
+
readonly NoSuchRecord: 30;
|
|
28
|
+
/** Field does not exist */
|
|
29
|
+
readonly NoSuchField: 31;
|
|
30
|
+
/** User does not exist */
|
|
31
|
+
readonly NoSuchUser: 33;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Error returned by the QuickBase XML API
|
|
35
|
+
*/
|
|
36
|
+
export declare class XmlError extends Error {
|
|
37
|
+
readonly code: number;
|
|
38
|
+
readonly text: string;
|
|
39
|
+
readonly detail?: string;
|
|
40
|
+
readonly action?: string;
|
|
41
|
+
constructor(code: number, text: string, detail?: string, action?: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if the response contains an error and throw if so.
|
|
45
|
+
* Returns void if successful (errcode === 0).
|
|
46
|
+
*/
|
|
47
|
+
export declare function checkError(resp: BaseResponse): void;
|
|
48
|
+
/**
|
|
49
|
+
* Check if the error is an authorization error (code 4 or 7)
|
|
50
|
+
*/
|
|
51
|
+
export declare function isUnauthorized(err: unknown): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if the error indicates a resource was not found
|
|
54
|
+
*/
|
|
55
|
+
export declare function isNotFound(err: unknown): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Check if the error indicates an invalid or expired authentication ticket
|
|
58
|
+
*/
|
|
59
|
+
export declare function isInvalidTicket(err: unknown): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Check if the error indicates invalid input parameters
|
|
62
|
+
*/
|
|
63
|
+
export declare function isInvalidInput(err: unknown): boolean;
|
|
64
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/xml/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,yBAAyB;;IAEzB,6CAA6C;;IAE7C,+BAA+B;;IAE/B,oCAAoC;;IAEpC,uCAAuC;;IAEvC,kDAAkD;;IAElD,4BAA4B;;IAE5B,2BAA2B;;IAE3B,0BAA0B;;CAElB,CAAC;AAEX;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEb,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAWzE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAKnD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAQpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAUhD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKrD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKpD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Errors
|
|
3
|
+
*
|
|
4
|
+
* Error handling for the legacy QuickBase XML API.
|
|
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
|
+
/**
|
|
10
|
+
* Common QuickBase XML API error codes
|
|
11
|
+
*/
|
|
12
|
+
export const XmlErrorCode = {
|
|
13
|
+
/** No error (success) */
|
|
14
|
+
Success: 0,
|
|
15
|
+
/** User is not authorized for this action */
|
|
16
|
+
Unauthorized: 4,
|
|
17
|
+
/** Invalid input parameters */
|
|
18
|
+
InvalidInput: 5,
|
|
19
|
+
/** Database/table does not exist */
|
|
20
|
+
NoSuchDatabase: 6,
|
|
21
|
+
/** Access to the resource is denied */
|
|
22
|
+
AccessDenied: 7,
|
|
23
|
+
/** Authentication ticket is invalid or expired */
|
|
24
|
+
InvalidTicket: 8,
|
|
25
|
+
/** Record does not exist */
|
|
26
|
+
NoSuchRecord: 30,
|
|
27
|
+
/** Field does not exist */
|
|
28
|
+
NoSuchField: 31,
|
|
29
|
+
/** User does not exist */
|
|
30
|
+
NoSuchUser: 33,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Error returned by the QuickBase XML API
|
|
34
|
+
*/
|
|
35
|
+
export class XmlError extends Error {
|
|
36
|
+
code;
|
|
37
|
+
text;
|
|
38
|
+
detail;
|
|
39
|
+
action;
|
|
40
|
+
constructor(code, text, detail, action) {
|
|
41
|
+
const msg = detail
|
|
42
|
+
? `XML API error ${code}: ${text} (${detail})`
|
|
43
|
+
: `XML API error ${code}: ${text}`;
|
|
44
|
+
super(msg);
|
|
45
|
+
this.name = 'XmlError';
|
|
46
|
+
this.code = code;
|
|
47
|
+
this.text = text;
|
|
48
|
+
this.detail = detail;
|
|
49
|
+
this.action = action;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if the response contains an error and throw if so.
|
|
54
|
+
* Returns void if successful (errcode === 0).
|
|
55
|
+
*/
|
|
56
|
+
export function checkError(resp) {
|
|
57
|
+
if (resp.errcode === 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
throw new XmlError(resp.errcode, resp.errtext, resp.errdetail, resp.action);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if the error is an authorization error (code 4 or 7)
|
|
64
|
+
*/
|
|
65
|
+
export function isUnauthorized(err) {
|
|
66
|
+
if (err instanceof XmlError) {
|
|
67
|
+
return (err.code === XmlErrorCode.Unauthorized ||
|
|
68
|
+
err.code === XmlErrorCode.AccessDenied);
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if the error indicates a resource was not found
|
|
74
|
+
*/
|
|
75
|
+
export function isNotFound(err) {
|
|
76
|
+
if (err instanceof XmlError) {
|
|
77
|
+
return (err.code === XmlErrorCode.NoSuchDatabase ||
|
|
78
|
+
err.code === XmlErrorCode.NoSuchRecord ||
|
|
79
|
+
err.code === XmlErrorCode.NoSuchField ||
|
|
80
|
+
err.code === XmlErrorCode.NoSuchUser);
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Check if the error indicates an invalid or expired authentication ticket
|
|
86
|
+
*/
|
|
87
|
+
export function isInvalidTicket(err) {
|
|
88
|
+
if (err instanceof XmlError) {
|
|
89
|
+
return err.code === XmlErrorCode.InvalidTicket;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if the error indicates invalid input parameters
|
|
95
|
+
*/
|
|
96
|
+
export function isInvalidInput(err) {
|
|
97
|
+
if (err instanceof XmlError) {
|
|
98
|
+
return err.code === XmlErrorCode.InvalidInput;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/xml/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,yBAAyB;IACzB,OAAO,EAAE,CAAC;IACV,6CAA6C;IAC7C,YAAY,EAAE,CAAC;IACf,+BAA+B;IAC/B,YAAY,EAAE,CAAC;IACf,oCAAoC;IACpC,cAAc,EAAE,CAAC;IACjB,uCAAuC;IACvC,YAAY,EAAE,CAAC;IACf,kDAAkD;IAClD,aAAa,EAAE,CAAC;IAChB,4BAA4B;IAC5B,YAAY,EAAE,EAAE;IAChB,2BAA2B;IAC3B,WAAW,EAAE,EAAE;IACf,0BAA0B;IAC1B,UAAU,EAAE,EAAE;CACN,CAAC;AAEX;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,IAAI,CAAS;IACb,MAAM,CAAU;IAChB,MAAM,CAAU;IAEzB,YAAY,IAAY,EAAE,IAAY,EAAE,MAAe,EAAE,MAAe;QACtE,MAAM,GAAG,GAAG,MAAM;YAChB,CAAC,CAAC,iBAAiB,IAAI,KAAK,IAAI,KAAK,MAAM,GAAG;YAC9C,CAAC,CAAC,iBAAiB,IAAI,KAAK,IAAI,EAAE,CAAC;QACrC,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAkB;IAC3C,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IACD,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAC5B,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY;YACtC,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY,CACvC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAY;IACrC,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAC5B,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,cAAc;YACxC,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY;YACtC,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,WAAW;YACrC,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,UAAU,CACrC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,aAAa,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Field Management
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing field properties.
|
|
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, FieldAddChoicesResult, FieldRemoveChoicesResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Add choices to a multiple-choice field.
|
|
12
|
+
*
|
|
13
|
+
* @see https://help.quickbase.com/docs/api-fieldaddchoices
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const result = await fieldAddChoices(caller, 'bqtable123', 6, ['Option A', 'Option B']);
|
|
18
|
+
* console.log(`Added ${result.numAdded} choices`);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function fieldAddChoices(caller: XmlCaller, tableId: string, fieldId: number, choices: string[]): Promise<FieldAddChoicesResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Remove choices from a multiple-choice field.
|
|
24
|
+
*
|
|
25
|
+
* @see https://help.quickbase.com/docs/api-fieldremovechoices
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const result = await fieldRemoveChoices(caller, 'bqtable123', 6, ['Option A']);
|
|
30
|
+
* console.log(`Removed ${result.numRemoved} choices`);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function fieldRemoveChoices(caller: XmlCaller, tableId: string, fieldId: number, choices: string[]): Promise<FieldRemoveChoicesResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Set the key field for a table.
|
|
36
|
+
*
|
|
37
|
+
* @see https://help.quickbase.com/docs/api-setkeyfield
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* await setKeyField(caller, 'bqtable123', 6);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function setKeyField(caller: XmlCaller, tableId: string, fieldId: number): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/xml/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAoBhC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,wBAAwB,CAAC,CAoBnC;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XML API Field Management
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing field properties.
|
|
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, parseXmlNumber, } from './request.js';
|
|
11
|
+
/**
|
|
12
|
+
* Add choices to a multiple-choice field.
|
|
13
|
+
*
|
|
14
|
+
* @see https://help.quickbase.com/docs/api-fieldaddchoices
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const result = await fieldAddChoices(caller, 'bqtable123', 6, ['Option A', 'Option B']);
|
|
19
|
+
* console.log(`Added ${result.numAdded} choices`);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export async function fieldAddChoices(caller, tableId, fieldId, choices) {
|
|
23
|
+
if (choices.length === 0) {
|
|
24
|
+
throw new Error('choices array cannot be empty');
|
|
25
|
+
}
|
|
26
|
+
let inner = `<fid>${fieldId}</fid>`;
|
|
27
|
+
for (const choice of choices) {
|
|
28
|
+
inner += `<choice>${escapeXml(choice)}</choice>`;
|
|
29
|
+
}
|
|
30
|
+
const body = buildRequest(inner);
|
|
31
|
+
const xml = await caller.doXml(tableId, 'API_FieldAddChoices', body);
|
|
32
|
+
const base = parseBaseResponse(xml);
|
|
33
|
+
checkError(base);
|
|
34
|
+
return {
|
|
35
|
+
fieldId,
|
|
36
|
+
fieldName: getTagContent(xml, 'fname') || '',
|
|
37
|
+
numAdded: parseXmlNumber(getTagContent(xml, 'numadded')),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Remove choices from a multiple-choice field.
|
|
42
|
+
*
|
|
43
|
+
* @see https://help.quickbase.com/docs/api-fieldremovechoices
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const result = await fieldRemoveChoices(caller, 'bqtable123', 6, ['Option A']);
|
|
48
|
+
* console.log(`Removed ${result.numRemoved} choices`);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export async function fieldRemoveChoices(caller, tableId, fieldId, choices) {
|
|
52
|
+
if (choices.length === 0) {
|
|
53
|
+
throw new Error('choices array cannot be empty');
|
|
54
|
+
}
|
|
55
|
+
let inner = `<fid>${fieldId}</fid>`;
|
|
56
|
+
for (const choice of choices) {
|
|
57
|
+
inner += `<choice>${escapeXml(choice)}</choice>`;
|
|
58
|
+
}
|
|
59
|
+
const body = buildRequest(inner);
|
|
60
|
+
const xml = await caller.doXml(tableId, 'API_FieldRemoveChoices', body);
|
|
61
|
+
const base = parseBaseResponse(xml);
|
|
62
|
+
checkError(base);
|
|
63
|
+
return {
|
|
64
|
+
fieldId,
|
|
65
|
+
fieldName: getTagContent(xml, 'fname') || '',
|
|
66
|
+
numRemoved: parseXmlNumber(getTagContent(xml, 'numremoved')),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set the key field for a table.
|
|
71
|
+
*
|
|
72
|
+
* @see https://help.quickbase.com/docs/api-setkeyfield
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* await setKeyField(caller, 'bqtable123', 6);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export async function setKeyField(caller, tableId, fieldId) {
|
|
80
|
+
const inner = `<fid>${fieldId}</fid>`;
|
|
81
|
+
const body = buildRequest(inner);
|
|
82
|
+
const xml = await caller.doXml(tableId, 'API_SetKeyField', body);
|
|
83
|
+
const base = parseBaseResponse(xml);
|
|
84
|
+
checkError(base);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/xml/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAiB,EACjB,OAAe,EACf,OAAe,EACf,OAAiB;IAEjB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,KAAK,GAAG,QAAQ,OAAO,QAAQ,CAAC;IACpC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,IAAI,WAAW,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC;IACnD,CAAC;IAED,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,IAAI,CAAC,CAAC;IAErE,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO;QACL,OAAO;QACP,SAAS,EAAE,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE;QAC5C,QAAQ,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;KACzD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAiB,EACjB,OAAe,EACf,OAAe,EACf,OAAiB;IAEjB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,KAAK,GAAG,QAAQ,OAAO,QAAQ,CAAC;IACpC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,IAAI,WAAW,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC;IACnD,CAAC;IAED,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,wBAAwB,EAAE,IAAI,CAAC,CAAC;IAExE,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO;QACL,OAAO;QACP,SAAS,EAAE,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE;QAC5C,UAAU,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAiB,EACjB,OAAe,EACf,OAAe;IAEf,MAAM,KAAK,GAAG,QAAQ,OAAO,QAAQ,CAAC;IACtC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAEjE,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpC,UAAU,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC"}
|