@codeqr/ts 0.24.1 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +1 -1
  3. package/README.md +28 -28
  4. package/client.d.mts +10 -10
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +10 -10
  7. package/client.d.ts.map +1 -1
  8. package/client.js +38 -38
  9. package/client.mjs +36 -36
  10. package/core/api-promise.d.mts +2 -2
  11. package/core/api-promise.d.ts +2 -2
  12. package/core/error.d.mts +2 -2
  13. package/core/error.d.ts +2 -2
  14. package/core/error.js +4 -4
  15. package/core/error.mjs +2 -2
  16. package/core/resource.d.mts +3 -3
  17. package/core/resource.d.ts +3 -3
  18. package/index.d.mts +3 -3
  19. package/index.d.ts +3 -3
  20. package/index.js +4 -4
  21. package/index.mjs +3 -3
  22. package/internal/parse.d.mts +2 -2
  23. package/internal/parse.d.ts +2 -2
  24. package/internal/shims.js +1 -1
  25. package/internal/shims.mjs +1 -1
  26. package/internal/uploads.d.mts +4 -4
  27. package/internal/uploads.d.ts +4 -4
  28. package/internal/utils/base64.js +2 -2
  29. package/internal/utils/base64.mjs +3 -3
  30. package/internal/utils/log.d.mts +3 -3
  31. package/internal/utils/log.d.ts +3 -3
  32. package/internal/utils/path.js +1 -1
  33. package/internal/utils/path.mjs +2 -2
  34. package/internal/utils/values.js +5 -5
  35. package/internal/utils/values.mjs +6 -6
  36. package/package.json +3 -3
  37. package/resources/analytics.d.mts +38 -5
  38. package/resources/analytics.d.mts.map +1 -1
  39. package/resources/analytics.d.ts +38 -5
  40. package/resources/analytics.d.ts.map +1 -1
  41. package/resources/domains.d.mts +26 -26
  42. package/resources/domains.d.mts.map +1 -1
  43. package/resources/domains.d.ts +26 -26
  44. package/resources/domains.d.ts.map +1 -1
  45. package/resources/domains.js +8 -8
  46. package/resources/domains.js.map +1 -1
  47. package/resources/domains.mjs +8 -8
  48. package/resources/domains.mjs.map +1 -1
  49. package/resources/events.d.mts +29 -72
  50. package/resources/events.d.mts.map +1 -1
  51. package/resources/events.d.ts +29 -72
  52. package/resources/events.d.ts.map +1 -1
  53. package/resources/index.d.mts +4 -4
  54. package/resources/index.d.mts.map +1 -1
  55. package/resources/index.d.ts +4 -4
  56. package/resources/index.d.ts.map +1 -1
  57. package/resources/links/bulk.d.mts +14 -5
  58. package/resources/links/bulk.d.mts.map +1 -1
  59. package/resources/links/bulk.d.ts +14 -5
  60. package/resources/links/bulk.d.ts.map +1 -1
  61. package/resources/links/index.d.mts +1 -1
  62. package/resources/links/index.d.mts.map +1 -1
  63. package/resources/links/index.d.ts +1 -1
  64. package/resources/links/index.d.ts.map +1 -1
  65. package/resources/links/links.d.mts +263 -237
  66. package/resources/links/links.d.mts.map +1 -1
  67. package/resources/links/links.d.ts +263 -237
  68. package/resources/links/links.d.ts.map +1 -1
  69. package/resources/links/links.js +21 -21
  70. package/resources/links/links.js.map +1 -1
  71. package/resources/links/links.mjs +21 -21
  72. package/resources/links/links.mjs.map +1 -1
  73. package/resources/qrcodes/bulk.d.mts +84 -17
  74. package/resources/qrcodes/bulk.d.mts.map +1 -1
  75. package/resources/qrcodes/bulk.d.ts +84 -17
  76. package/resources/qrcodes/bulk.d.ts.map +1 -1
  77. package/resources/qrcodes/index.d.mts +1 -1
  78. package/resources/qrcodes/index.d.mts.map +1 -1
  79. package/resources/qrcodes/index.d.ts +1 -1
  80. package/resources/qrcodes/index.d.ts.map +1 -1
  81. package/resources/qrcodes/qrcodes.d.mts +409 -223
  82. package/resources/qrcodes/qrcodes.d.mts.map +1 -1
  83. package/resources/qrcodes/qrcodes.d.ts +409 -223
  84. package/resources/qrcodes/qrcodes.d.ts.map +1 -1
  85. package/resources/qrcodes/qrcodes.js +11 -11
  86. package/resources/qrcodes/qrcodes.js.map +1 -1
  87. package/resources/qrcodes/qrcodes.mjs +11 -11
  88. package/resources/qrcodes/qrcodes.mjs.map +1 -1
  89. package/resources/tags.d.mts +12 -12
  90. package/resources/tags.d.mts.map +1 -1
  91. package/resources/tags.d.ts +12 -12
  92. package/resources/tags.d.ts.map +1 -1
  93. package/resources/tags.js +6 -6
  94. package/resources/tags.js.map +1 -1
  95. package/resources/tags.mjs +6 -6
  96. package/resources/tags.mjs.map +1 -1
  97. package/resources/track.d.mts +12 -0
  98. package/resources/track.d.mts.map +1 -1
  99. package/resources/track.d.ts +12 -0
  100. package/resources/track.d.ts.map +1 -1
  101. package/src/client.ts +21 -21
  102. package/src/core/api-promise.ts +4 -4
  103. package/src/core/error.ts +2 -2
  104. package/src/core/resource.ts +3 -3
  105. package/src/index.ts +3 -3
  106. package/src/internal/parse.ts +2 -2
  107. package/src/internal/shims.ts +1 -1
  108. package/src/internal/uploads.ts +5 -5
  109. package/src/internal/utils/base64.ts +3 -3
  110. package/src/internal/utils/log.ts +3 -3
  111. package/src/internal/utils/path.ts +2 -2
  112. package/src/internal/utils/values.ts +6 -6
  113. package/src/resources/analytics.ts +45 -5
  114. package/src/resources/domains.ts +37 -37
  115. package/src/resources/events.ts +48 -82
  116. package/src/resources/index.ts +4 -4
  117. package/src/resources/links/bulk.ts +23 -6
  118. package/src/resources/links/index.ts +1 -1
  119. package/src/resources/links/links.ts +328 -257
  120. package/src/resources/qrcodes/bulk.ts +103 -17
  121. package/src/resources/qrcodes/index.ts +1 -1
  122. package/src/resources/qrcodes/qrcodes.ts +629 -368
  123. package/src/resources/tags.ts +16 -16
  124. package/src/resources/track.ts +14 -0
  125. package/src/version.ts +1 -1
  126. package/version.d.mts +1 -1
  127. package/version.d.ts +1 -1
  128. package/version.js +1 -1
  129. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -160,9 +160,9 @@ export interface ClientOptions {
160
160
  }
161
161
 
162
162
  /**
163
- * API Client for interfacing with the Codeqr API.
163
+ * API Client for interfacing with the CodeQR API.
164
164
  */
165
- export class Codeqr {
165
+ export class CodeQR {
166
166
  apiKey: string;
167
167
 
168
168
  baseURL: string;
@@ -178,7 +178,7 @@ export class Codeqr {
178
178
  private _options: ClientOptions;
179
179
 
180
180
  /**
181
- * API Client for interfacing with the Codeqr API.
181
+ * API Client for interfacing with the CodeQR API.
182
182
  *
183
183
  * @param {string | undefined} [opts.apiKey=process.env['CODEQR_API_KEY'] ?? undefined]
184
184
  * @param {string} [opts.baseURL=process.env['CODEQR_BASE_URL'] ?? https://api.codeqr.io] - Override the default base URL for the API.
@@ -195,8 +195,8 @@ export class Codeqr {
195
195
  ...opts
196
196
  }: ClientOptions = {}) {
197
197
  if (apiKey === undefined) {
198
- throw new Errors.CodeqrError(
199
- "The CODEQR_API_KEY environment variable is missing or empty; either provide it, or instantiate the Codeqr client with an apiKey option, like new Codeqr({ apiKey: 'My API Key' }).",
198
+ throw new Errors.CodeQRError(
199
+ "The CODEQR_API_KEY environment variable is missing or empty; either provide it, or instantiate the CodeQR client with an apiKey option, like new CodeQR({ apiKey: 'My API Key' }).",
200
200
  );
201
201
  }
202
202
 
@@ -207,7 +207,7 @@ export class Codeqr {
207
207
  };
208
208
 
209
209
  this.baseURL = options.baseURL!;
210
- this.timeout = options.timeout ?? Codeqr.DEFAULT_TIMEOUT /* 1 minute */;
210
+ this.timeout = options.timeout ?? CodeQR.DEFAULT_TIMEOUT /* 1 minute */;
211
211
  this.logger = options.logger ?? console;
212
212
  const defaultLogLevel = 'warn';
213
213
  // Set default logLevel early so that we can log a warning in parseLogLevel.
@@ -769,10 +769,10 @@ export class Codeqr {
769
769
  }
770
770
  }
771
771
 
772
- static Codeqr = this;
772
+ static CodeQR = this;
773
773
  static DEFAULT_TIMEOUT = 60000; // 1 minute
774
774
 
775
- static CodeqrError = Errors.CodeqrError;
775
+ static CodeQRError = Errors.CodeQRError;
776
776
  static APIError = Errors.APIError;
777
777
  static APIConnectionError = Errors.APIConnectionError;
778
778
  static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
@@ -798,16 +798,16 @@ export class Codeqr {
798
798
  projects: API.Projects = new API.Projects(this);
799
799
  }
800
800
 
801
- Codeqr.Links = Links;
802
- Codeqr.Qrcodes = Qrcodes;
803
- Codeqr.Analytics = Analytics;
804
- Codeqr.Events = Events;
805
- Codeqr.Tags = Tags;
806
- Codeqr.Domains = Domains;
807
- Codeqr.Track = Track;
808
- Codeqr.Projects = Projects;
801
+ CodeQR.Links = Links;
802
+ CodeQR.Qrcodes = Qrcodes;
803
+ CodeQR.Analytics = Analytics;
804
+ CodeQR.Events = Events;
805
+ CodeQR.Tags = Tags;
806
+ CodeQR.Domains = Domains;
807
+ CodeQR.Track = Track;
808
+ CodeQR.Projects = Projects;
809
809
 
810
- export declare namespace Codeqr {
810
+ export declare namespace CodeQR {
811
811
  export type RequestOptions = Opts.RequestOptions;
812
812
 
813
813
  export {
@@ -816,9 +816,9 @@ export declare namespace Codeqr {
816
816
  type LinkListResponse as LinkListResponse,
817
817
  type LinkDeleteResponse as LinkDeleteResponse,
818
818
  type LinkCreateParams as LinkCreateParams,
819
+ type LinkUpdateParams as LinkUpdateParams,
819
820
  type LinkListParams as LinkListParams,
820
821
  type LinkRetrieveInfoParams as LinkRetrieveInfoParams,
821
- type LinkUpdateParams as LinkUpdateParams,
822
822
  };
823
823
 
824
824
  export {
@@ -827,9 +827,9 @@ export declare namespace Codeqr {
827
827
  type QrcodeListResponse as QrcodeListResponse,
828
828
  type QrcodeDeleteResponse as QrcodeDeleteResponse,
829
829
  type QrcodeCreateParams as QrcodeCreateParams,
830
- type QrcodeListParams as QrcodeListParams,
831
830
  type QrcodeRetrieveParams as QrcodeRetrieveParams,
832
831
  type QrcodeUpdateParams as QrcodeUpdateParams,
832
+ type QrcodeListParams as QrcodeListParams,
833
833
  };
834
834
 
835
835
  export {
@@ -852,8 +852,8 @@ export declare namespace Codeqr {
852
852
  type TagListResponse as TagListResponse,
853
853
  type TagDeleteResponse as TagDeleteResponse,
854
854
  type TagCreateParams as TagCreateParams,
855
- type TagListParams as TagListParams,
856
855
  type TagUpdateParams as TagUpdateParams,
856
+ type TagListParams as TagListParams,
857
857
  };
858
858
 
859
859
  export {
@@ -862,8 +862,8 @@ export declare namespace Codeqr {
862
862
  type DomainListResponse as DomainListResponse,
863
863
  type DomainDeleteResponse as DomainDeleteResponse,
864
864
  type DomainCreateParams as DomainCreateParams,
865
- type DomainListParams as DomainListParams,
866
865
  type DomainUpdateParams as DomainUpdateParams,
866
+ type DomainListParams as DomainListParams,
867
867
  };
868
868
 
869
869
  export {
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { type Codeqr } from '../client';
3
+ import { type CodeQR } from '../client';
4
4
 
5
5
  import { type PromiseOrValue } from '../internal/types';
6
6
  import { APIResponseProps, defaultParseResponse } from '../internal/parse';
@@ -11,13 +11,13 @@ import { APIResponseProps, defaultParseResponse } from '../internal/parse';
11
11
  */
12
12
  export class APIPromise<T> extends Promise<T> {
13
13
  private parsedPromise: Promise<T> | undefined;
14
- #client: Codeqr;
14
+ #client: CodeQR;
15
15
 
16
16
  constructor(
17
- client: Codeqr,
17
+ client: CodeQR,
18
18
  private responsePromise: Promise<APIResponseProps>,
19
19
  private parseResponse: (
20
- client: Codeqr,
20
+ client: CodeQR,
21
21
  props: APIResponseProps,
22
22
  ) => PromiseOrValue<T> = defaultParseResponse,
23
23
  ) {
package/src/core/error.ts CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  import { castToError } from '../internal/errors';
4
4
 
5
- export class CodeqrError extends Error {}
5
+ export class CodeQRError extends Error {}
6
6
 
7
7
  export class APIError<
8
8
  TStatus extends number | undefined = number | undefined,
9
9
  THeaders extends Headers | undefined = Headers | undefined,
10
10
  TError extends Object | undefined = Object | undefined,
11
- > extends CodeqrError {
11
+ > extends CodeQRError {
12
12
  /** HTTP status for the response that caused the error */
13
13
  readonly status: TStatus;
14
14
  /** HTTP headers for the response that caused the error */
@@ -1,11 +1,11 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import type { Codeqr } from '../client';
3
+ import type { CodeQR } from '../client';
4
4
 
5
5
  export abstract class APIResource {
6
- protected _client: Codeqr;
6
+ protected _client: CodeQR;
7
7
 
8
- constructor(client: Codeqr) {
8
+ constructor(client: CodeQR) {
9
9
  this._client = client;
10
10
  }
11
11
  }
package/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { Codeqr as default } from './client';
3
+ export { CodeQR as default } from './client';
4
4
 
5
5
  export { type Uploadable, toFile } from './core/uploads';
6
6
  export { APIPromise } from './core/api-promise';
7
- export { Codeqr, type ClientOptions } from './client';
7
+ export { CodeQR, type ClientOptions } from './client';
8
8
  export {
9
- CodeqrError,
9
+ CodeQRError,
10
10
  APIError,
11
11
  APIConnectionError,
12
12
  APIConnectionTimeoutError,
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import type { FinalRequestOptions } from './request-options';
4
- import { type Codeqr } from '../client';
4
+ import { type CodeQR } from '../client';
5
5
  import { formatRequestDetails, loggerFor } from './utils/log';
6
6
 
7
7
  export type APIResponseProps = {
@@ -13,7 +13,7 @@ export type APIResponseProps = {
13
13
  startTime: number;
14
14
  };
15
15
 
16
- export async function defaultParseResponse<T>(client: Codeqr, props: APIResponseProps): Promise<T> {
16
+ export async function defaultParseResponse<T>(client: CodeQR, props: APIResponseProps): Promise<T> {
17
17
  const { response, requestLogID, retryOfRequestLogID, startTime } = props;
18
18
  const body = await (async () => {
19
19
  // fetch refuses to read the body when the status code is 204.
@@ -16,7 +16,7 @@ export function getDefaultFetch(): Fetch {
16
16
  }
17
17
 
18
18
  throw new Error(
19
- '`fetch` is not defined as a global; Either pass `fetch` to the client, `new Codeqr({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
19
+ '`fetch` is not defined as a global; Either pass `fetch` to the client, `new CodeQR({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
20
20
  );
21
21
  }
22
22
 
@@ -1,6 +1,6 @@
1
1
  import { type RequestOptions } from './request-options';
2
2
  import type { FilePropertyBag, Fetch } from './builtin-types';
3
- import type { Codeqr } from '../client';
3
+ import type { CodeQR } from '../client';
4
4
  import { ReadableStreamFrom } from './shims';
5
5
 
6
6
  export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
@@ -74,7 +74,7 @@ export const isAsyncIterable = (value: any): value is AsyncIterable<any> =>
74
74
  */
75
75
  export const maybeMultipartFormRequestOptions = async (
76
76
  opts: RequestOptions,
77
- fetch: Codeqr | Fetch,
77
+ fetch: CodeQR | Fetch,
78
78
  ): Promise<RequestOptions> => {
79
79
  if (!hasUploadableValue(opts.body)) return opts;
80
80
 
@@ -85,7 +85,7 @@ type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & { body: unknow
85
85
 
86
86
  export const multipartFormRequestOptions = async (
87
87
  opts: MultipartFormRequestOptions,
88
- fetch: Codeqr | Fetch,
88
+ fetch: CodeQR | Fetch,
89
89
  ): Promise<RequestOptions> => {
90
90
  return { ...opts, body: await createForm(opts.body, fetch) };
91
91
  };
@@ -98,7 +98,7 @@ const supportsFormDataMap = /* @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>
98
98
  * This function detects if the fetch function provided supports the global FormData object to avoid
99
99
  * confusing error messages later on.
100
100
  */
101
- function supportsFormData(fetchObject: Codeqr | Fetch): Promise<boolean> {
101
+ function supportsFormData(fetchObject: CodeQR | Fetch): Promise<boolean> {
102
102
  const fetch: Fetch = typeof fetchObject === 'function' ? fetchObject : (fetchObject as any).fetch;
103
103
  const cached = supportsFormDataMap.get(fetch);
104
104
  if (cached) return cached;
@@ -124,7 +124,7 @@ function supportsFormData(fetchObject: Codeqr | Fetch): Promise<boolean> {
124
124
 
125
125
  export const createForm = async <T = Record<string, unknown>>(
126
126
  body: T | undefined,
127
- fetch: Codeqr | Fetch,
127
+ fetch: CodeQR | Fetch,
128
128
  ): Promise<FormData> => {
129
129
  if (!(await supportsFormData(fetch))) {
130
130
  throw new TypeError(
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { CodeqrError } from '../../core/error';
3
+ import { CodeQRError } from '../../core/error';
4
4
  import { encodeUTF8 } from './bytes';
5
5
 
6
6
  export const toBase64 = (data: string | Uint8Array | null | undefined): string => {
@@ -18,7 +18,7 @@ export const toBase64 = (data: string | Uint8Array | null | undefined): string =
18
18
  return btoa(String.fromCharCode.apply(null, data as any));
19
19
  }
20
20
 
21
- throw new CodeqrError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
21
+ throw new CodeQRError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
22
22
  };
23
23
 
24
24
  export const fromBase64 = (str: string): Uint8Array => {
@@ -36,5 +36,5 @@ export const fromBase64 = (str: string): Uint8Array => {
36
36
  return buf;
37
37
  }
38
38
 
39
- throw new CodeqrError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
39
+ throw new CodeQRError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
40
40
  };
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { hasOwn } from './values';
4
- import { type Codeqr } from '../../client';
4
+ import { type CodeQR } from '../../client';
5
5
  import { RequestOptions } from '../request-options';
6
6
 
7
7
  type LogFn = (message: string, ...rest: unknown[]) => void;
@@ -24,7 +24,7 @@ const levelNumbers = {
24
24
  export const parseLogLevel = (
25
25
  maybeLevel: string | undefined,
26
26
  sourceName: string,
27
- client: Codeqr,
27
+ client: CodeQR,
28
28
  ): LogLevel | undefined => {
29
29
  if (!maybeLevel) {
30
30
  return undefined;
@@ -60,7 +60,7 @@ const noopLogger = {
60
60
 
61
61
  let cachedLoggers = /* @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
62
62
 
63
- export function loggerFor(client: Codeqr): Logger {
63
+ export function loggerFor(client: CodeQR): Logger {
64
64
  const logger = client.logger;
65
65
  const logLevel = client.logLevel ?? 'off';
66
66
  if (!logger) {
@@ -1,4 +1,4 @@
1
- import { CodeqrError } from '../../core/error';
1
+ import { CodeQRError } from '../../core/error';
2
2
 
3
3
  /**
4
4
  * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
@@ -72,7 +72,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
72
72
  return acc + spaces + arrows;
73
73
  }, '');
74
74
 
75
- throw new CodeqrError(
75
+ throw new CodeQRError(
76
76
  `Path parameters result in path with invalid segments:\n${invalidSegments
77
77
  .map((e) => e.error)
78
78
  .join('\n')}\n${path}\n${underline}`,
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { CodeqrError } from '../../core/error';
3
+ import { CodeQRError } from '../../core/error';
4
4
 
5
5
  // https://url.spec.whatwg.org/#url-scheme-string
6
6
  const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
@@ -39,7 +39,7 @@ export function isObj(obj: unknown): obj is Record<string, unknown> {
39
39
 
40
40
  export const ensurePresent = <T>(value: T | null | undefined): T => {
41
41
  if (value == null) {
42
- throw new CodeqrError(`Expected a value to be given but received ${value} instead.`);
42
+ throw new CodeQRError(`Expected a value to be given but received ${value} instead.`);
43
43
  }
44
44
 
45
45
  return value;
@@ -47,10 +47,10 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
47
47
 
48
48
  export const validatePositiveInteger = (name: string, n: unknown): number => {
49
49
  if (typeof n !== 'number' || !Number.isInteger(n)) {
50
- throw new CodeqrError(`${name} must be an integer`);
50
+ throw new CodeQRError(`${name} must be an integer`);
51
51
  }
52
52
  if (n < 0) {
53
- throw new CodeqrError(`${name} must be a positive integer`);
53
+ throw new CodeQRError(`${name} must be a positive integer`);
54
54
  }
55
55
  return n;
56
56
  };
@@ -59,14 +59,14 @@ export const coerceInteger = (value: unknown): number => {
59
59
  if (typeof value === 'number') return Math.round(value);
60
60
  if (typeof value === 'string') return parseInt(value, 10);
61
61
 
62
- throw new CodeqrError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
62
+ throw new CodeQRError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
63
63
  };
64
64
 
65
65
  export const coerceFloat = (value: unknown): number => {
66
66
  if (typeof value === 'number') return value;
67
67
  if (typeof value === 'string') return parseFloat(value);
68
68
 
69
- throw new CodeqrError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
69
+ throw new CodeQRError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
70
70
  };
71
71
 
72
72
  export const coerceBoolean = (value: unknown): boolean => {
@@ -290,7 +290,8 @@ export type AnalyticsRetrieveResponse =
290
290
  | Array<AnalyticsRetrieveResponse.AnalyticsReferer>
291
291
  | Array<AnalyticsRetrieveResponse.AnalyticsRefererURL>
292
292
  | Array<AnalyticsRetrieveResponse.AnalyticsTopLink>
293
- | Array<AnalyticsRetrieveResponse.AnalyticsTopURL>;
293
+ | Array<AnalyticsRetrieveResponse.AnalyticsTopURL>
294
+ | Array<AnalyticsRetrieveResponse.AnalyticsTrigger>;
294
295
 
295
296
  export namespace AnalyticsRetrieveResponse {
296
297
  export interface AnalyticsCount {
@@ -1330,7 +1331,8 @@ export namespace AnalyticsRetrieveResponse {
1330
1331
  leads: number;
1331
1332
 
1332
1333
  /**
1333
- * The name of the referer. If unknown, this will be `(direct)`
1334
+ * The name of the referer. If unknown, this will be `(direct)`. `nfc` marks an
1335
+ * access whose URL carried the chip marker (`?nfc=1`) and had no web referer.
1334
1336
  */
1335
1337
  referer: string;
1336
1338
 
@@ -1445,6 +1447,36 @@ export namespace AnalyticsRetrieveResponse {
1445
1447
  */
1446
1448
  url: string;
1447
1449
  }
1450
+
1451
+ export interface AnalyticsTrigger {
1452
+ /**
1453
+ * The number of clicks from this trigger method
1454
+ */
1455
+ clicks: number;
1456
+
1457
+ /**
1458
+ * The number of leads from this trigger method
1459
+ */
1460
+ leads: number;
1461
+
1462
+ /**
1463
+ * The total amount of sales from this trigger method, in cents
1464
+ */
1465
+ saleAmount: number;
1466
+
1467
+ /**
1468
+ * The number of sales from this trigger method
1469
+ */
1470
+ sales: number;
1471
+
1472
+ /**
1473
+ * How the visitor reached the item: `nfc` when the URL carried the chip marker
1474
+ * (`?nfc=1`), `qr` for a QR Code scan, `link` otherwise (pages included). The
1475
+ * channel is declared by the URL written to the tag; it does not prove a physical
1476
+ * tap.
1477
+ */
1478
+ trigger: 'link' | 'qr' | 'nfc';
1479
+ }
1448
1480
  }
1449
1481
 
1450
1482
  export interface AnalyticsRetrieveParams {
@@ -1502,7 +1534,12 @@ export interface AnalyticsRetrieveParams {
1502
1534
 
1503
1535
  /**
1504
1536
  * The parameter to group the analytics data points by. Defaults to 'count' if
1505
- * undefined.
1537
+ * undefined. Some values depend on the workspace plan and answer 403 `forbidden`
1538
+ * on a plan without them: `referers` and `referer_urls` need the Starter, Pro,
1539
+ * Business, Scale, or Enterprise plan; `devices`, `browsers`, and `os` need the
1540
+ * Starter, Pro, Business, Scale, or Enterprise plan; `utm_sources`, `utm_mediums`,
1541
+ * `utm_campaigns`, `utm_contents`, and `utm_terms` need the Pro, Business, Scale,
1542
+ * or Enterprise plan.
1506
1543
  */
1507
1544
  groupBy?:
1508
1545
  | 'timeseries'
@@ -1537,7 +1574,8 @@ export interface AnalyticsRetrieveParams {
1537
1574
  | 'utm_mediums'
1538
1575
  | 'utm_campaigns'
1539
1576
  | 'utm_contents'
1540
- | 'utm_terms';
1577
+ | 'utm_terms'
1578
+ | 'trigger';
1541
1579
 
1542
1580
  /**
1543
1581
  * The interval to retrieve analytics for. Takes precedence over start and end.
@@ -1607,7 +1645,9 @@ export interface AnalyticsRetrieveParams {
1607
1645
  types?: string;
1608
1646
 
1609
1647
  /**
1610
- * The URL to retrieve analytics for.
1648
+ * The destination URL to retrieve analytics for. Match it without the query params
1649
+ * CodeQR copies off the click (UTM and ad click IDs such as fbclid or gclid):
1650
+ * those differ per visitor, so a URL carrying them matches at most one click.
1611
1651
  */
1612
1652
  url?: string;
1613
1653
 
@@ -21,34 +21,34 @@ export class Domains extends APIResource {
21
21
  }
22
22
 
23
23
  /**
24
- * Retrieve a list of domains associated with the authenticated workspace.
24
+ * Update a domain for the authenticated workspace.
25
25
  *
26
26
  * @example
27
27
  * ```ts
28
- * const domains = await client.domains.list();
28
+ * const domain = await client.domains.update('acme.com');
29
29
  * ```
30
30
  */
31
- list(
32
- query: DomainListParams | null | undefined = {},
31
+ update(
32
+ slug: string,
33
+ body: DomainUpdateParams | null | undefined = {},
33
34
  options?: RequestOptions,
34
- ): APIPromise<DomainListResponse> {
35
- return this._client.get('/domains', { query, ...options });
35
+ ): APIPromise<Domain> {
36
+ return this._client.patch(path`/domains/${slug}`, { body, ...options });
36
37
  }
37
38
 
38
39
  /**
39
- * Update a domain for the authenticated workspace.
40
+ * Retrieve a list of domains associated with the authenticated workspace.
40
41
  *
41
42
  * @example
42
43
  * ```ts
43
- * const domain = await client.domains.update('acme.com');
44
+ * const domains = await client.domains.list();
44
45
  * ```
45
46
  */
46
- update(
47
- slug: string,
48
- body: DomainUpdateParams | null | undefined = {},
47
+ list(
48
+ query: DomainListParams | null | undefined = {},
49
49
  options?: RequestOptions,
50
- ): APIPromise<Domain> {
51
- return this._client.patch(path`/domains/${slug}`, { body, ...options });
50
+ ): APIPromise<DomainListResponse> {
51
+ return this._client.get('/domains', { query, ...options });
52
52
  }
53
53
 
54
54
  /**
@@ -166,29 +166,6 @@ export interface DomainCreateParams {
166
166
  type?: 'redirect' | 'rewrite';
167
167
  }
168
168
 
169
- export interface DomainListParams {
170
- /**
171
- * Whether to include archived domains in the response. Defaults to `false` if not
172
- * provided.
173
- */
174
- archived?: boolean;
175
-
176
- /**
177
- * The page number for pagination.
178
- */
179
- page?: number;
180
-
181
- /**
182
- * The number of items per page.
183
- */
184
- pageSize?: number;
185
-
186
- /**
187
- * The search term to filter the domains by.
188
- */
189
- search?: string;
190
- }
191
-
192
169
  export interface DomainUpdateParams {
193
170
  /**
194
171
  * Whether to archive this domain. `false` will unarchive a previously archived
@@ -223,13 +200,36 @@ export interface DomainUpdateParams {
223
200
  type?: 'redirect' | 'rewrite';
224
201
  }
225
202
 
203
+ export interface DomainListParams {
204
+ /**
205
+ * Whether to include archived domains in the response. Defaults to `false` if not
206
+ * provided.
207
+ */
208
+ archived?: boolean;
209
+
210
+ /**
211
+ * The page number for pagination.
212
+ */
213
+ page?: number;
214
+
215
+ /**
216
+ * The number of items per page.
217
+ */
218
+ pageSize?: number;
219
+
220
+ /**
221
+ * The search term to filter the domains by.
222
+ */
223
+ search?: string;
224
+ }
225
+
226
226
  export declare namespace Domains {
227
227
  export {
228
228
  type Domain as Domain,
229
229
  type DomainListResponse as DomainListResponse,
230
230
  type DomainDeleteResponse as DomainDeleteResponse,
231
231
  type DomainCreateParams as DomainCreateParams,
232
- type DomainListParams as DomainListParams,
233
232
  type DomainUpdateParams as DomainUpdateParams,
233
+ type DomainListParams as DomainListParams,
234
234
  };
235
235
  }