influship 0.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/CHANGELOG.md +62 -0
- package/LICENSE +201 -0
- package/README.md +372 -0
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +198 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +198 -0
- package/client.d.ts.map +1 -0
- package/client.js +469 -0
- package/client.js.map +1 -0
- package/client.mjs +465 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +2 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +2 -0
- package/error.d.ts.map +1 -0
- package/error.js +6 -0
- package/error.js.map +1 -0
- package/error.mjs +2 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +6 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +30 -0
- package/index.js.map +1 -0
- package/index.mjs +7 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +20 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +20 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +35 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/request-options.d.mts +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +86 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +80 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +138 -0
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +6 -0
- package/resource.js.map +1 -0
- package/resource.mjs +2 -0
- package/resource.mjs.map +1 -0
- package/resources/brand-safety.d.mts +234 -0
- package/resources/brand-safety.d.mts.map +1 -0
- package/resources/brand-safety.d.ts +234 -0
- package/resources/brand-safety.d.ts.map +1 -0
- package/resources/brand-safety.js +75 -0
- package/resources/brand-safety.js.map +1 -0
- package/resources/brand-safety.mjs +71 -0
- package/resources/brand-safety.mjs.map +1 -0
- package/resources/creators.d.mts +364 -0
- package/resources/creators.d.mts.map +1 -0
- package/resources/creators.d.ts +364 -0
- package/resources/creators.d.ts.map +1 -0
- package/resources/creators.js +119 -0
- package/resources/creators.js.map +1 -0
- package/resources/creators.mjs +115 -0
- package/resources/creators.mjs.map +1 -0
- package/resources/health.d.mts +17 -0
- package/resources/health.d.mts.map +1 -0
- package/resources/health.d.ts +17 -0
- package/resources/health.d.ts.map +1 -0
- package/resources/health.js +15 -0
- package/resources/health.js.map +1 -0
- package/resources/health.mjs +11 -0
- package/resources/health.mjs.map +1 -0
- package/resources/index.d.mts +9 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +9 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +21 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +10 -0
- package/resources/index.mjs.map +1 -0
- package/resources/lookalike.d.mts +142 -0
- package/resources/lookalike.d.mts.map +1 -0
- package/resources/lookalike.d.ts +142 -0
- package/resources/lookalike.d.ts.map +1 -0
- package/resources/lookalike.js +28 -0
- package/resources/lookalike.js.map +1 -0
- package/resources/lookalike.mjs +24 -0
- package/resources/lookalike.mjs.map +1 -0
- package/resources/match.d.mts +90 -0
- package/resources/match.d.mts.map +1 -0
- package/resources/match.d.ts +90 -0
- package/resources/match.d.ts.map +1 -0
- package/resources/match.js +22 -0
- package/resources/match.js.map +1 -0
- package/resources/match.mjs +18 -0
- package/resources/match.mjs.map +1 -0
- package/resources/posts.d.mts +284 -0
- package/resources/posts.d.mts.map +1 -0
- package/resources/posts.d.ts +284 -0
- package/resources/posts.d.ts.map +1 -0
- package/resources/posts.js +55 -0
- package/resources/posts.js.map +1 -0
- package/resources/posts.mjs +51 -0
- package/resources/posts.mjs.map +1 -0
- package/resources/profiles.d.mts +99 -0
- package/resources/profiles.d.mts.map +1 -0
- package/resources/profiles.d.ts +99 -0
- package/resources/profiles.d.ts.map +1 -0
- package/resources/profiles.js +69 -0
- package/resources/profiles.js.map +1 -0
- package/resources/profiles.mjs +65 -0
- package/resources/profiles.mjs.map +1 -0
- package/resources/search.d.mts +189 -0
- package/resources/search.d.mts.map +1 -0
- package/resources/search.d.ts +189 -0
- package/resources/search.d.ts.map +1 -0
- package/resources/search.js +33 -0
- package/resources/search.js.map +1 -0
- package/resources/search.mjs +29 -0
- package/resources/search.mjs.map +1 -0
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +845 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +22 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +50 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/request-options.ts +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +127 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +8 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +2 -0
- package/src/resources/brand-safety.ts +304 -0
- package/src/resources/creators.ts +450 -0
- package/src/resources/health.ts +24 -0
- package/src/resources/index.ts +62 -0
- package/src/resources/lookalike.ts +186 -0
- package/src/resources/match.ts +115 -0
- package/src/resources/posts.ts +347 -0
- package/src/resources/profiles.ts +114 -0
- package/src/resources/search.ts +234 -0
- package/src/resources.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +2 -0
- package/src/version.ts +1 -0
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +2 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +6 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +2 -0
- package/uploads.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { InflushipAPIError } from '../../core/error';
|
|
4
|
+
|
|
5
|
+
// https://url.spec.whatwg.org/#url-scheme-string
|
|
6
|
+
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
7
|
+
|
|
8
|
+
export const isAbsoluteURL = (url: string): boolean => {
|
|
9
|
+
return startsWithSchemeRegexp.test(url);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export let isArray = (val: unknown): val is unknown[] => ((isArray = Array.isArray), isArray(val));
|
|
13
|
+
export let isReadonlyArray = isArray as (val: unknown) => val is readonly unknown[];
|
|
14
|
+
|
|
15
|
+
/** Returns an object if the given value isn't an object, otherwise returns as-is */
|
|
16
|
+
export function maybeObj(x: unknown): object {
|
|
17
|
+
if (typeof x !== 'object') {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return x ?? {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// https://stackoverflow.com/a/34491287
|
|
25
|
+
export function isEmptyObj(obj: Object | null | undefined): boolean {
|
|
26
|
+
if (!obj) return true;
|
|
27
|
+
for (const _k in obj) return false;
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
32
|
+
export function hasOwn<T extends object = object>(obj: T, key: PropertyKey): key is keyof T {
|
|
33
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isObj(obj: unknown): obj is Record<string, unknown> {
|
|
37
|
+
return obj != null && typeof obj === 'object' && !Array.isArray(obj);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const ensurePresent = <T>(value: T | null | undefined): T => {
|
|
41
|
+
if (value == null) {
|
|
42
|
+
throw new InflushipAPIError(`Expected a value to be given but received ${value} instead.`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return value;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const validatePositiveInteger = (name: string, n: unknown): number => {
|
|
49
|
+
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
50
|
+
throw new InflushipAPIError(`${name} must be an integer`);
|
|
51
|
+
}
|
|
52
|
+
if (n < 0) {
|
|
53
|
+
throw new InflushipAPIError(`${name} must be a positive integer`);
|
|
54
|
+
}
|
|
55
|
+
return n;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const coerceInteger = (value: unknown): number => {
|
|
59
|
+
if (typeof value === 'number') return Math.round(value);
|
|
60
|
+
if (typeof value === 'string') return parseInt(value, 10);
|
|
61
|
+
|
|
62
|
+
throw new InflushipAPIError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const coerceFloat = (value: unknown): number => {
|
|
66
|
+
if (typeof value === 'number') return value;
|
|
67
|
+
if (typeof value === 'string') return parseFloat(value);
|
|
68
|
+
|
|
69
|
+
throw new InflushipAPIError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const coerceBoolean = (value: unknown): boolean => {
|
|
73
|
+
if (typeof value === 'boolean') return value;
|
|
74
|
+
if (typeof value === 'string') return value === 'true';
|
|
75
|
+
return Boolean(value);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const maybeCoerceInteger = (value: unknown): number | undefined => {
|
|
79
|
+
if (value == null) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
return coerceInteger(value);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const maybeCoerceFloat = (value: unknown): number | undefined => {
|
|
86
|
+
if (value == null) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return coerceFloat(value);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
|
|
93
|
+
if (value == null) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return coerceBoolean(value);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const safeJSON = (text: string) => {
|
|
100
|
+
try {
|
|
101
|
+
return JSON.parse(text);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export * from './utils/values';
|
|
4
|
+
export * from './utils/base64';
|
|
5
|
+
export * from './utils/env';
|
|
6
|
+
export * from './utils/log';
|
|
7
|
+
export * from './utils/uuid';
|
|
8
|
+
export * from './utils/sleep';
|
package/src/lib/.keep
ADDED
package/src/resource.ts
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../core/resource';
|
|
4
|
+
import * as ProfilesAPI from './profiles';
|
|
5
|
+
import { APIPromise } from '../core/api-promise';
|
|
6
|
+
import { RequestOptions } from '../internal/request-options';
|
|
7
|
+
|
|
8
|
+
export class BrandSafety extends APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* Analyze creators for brand safety risks using AI-powered content analysis.
|
|
11
|
+
*
|
|
12
|
+
* This endpoint evaluates creators for potential brand safety issues including
|
|
13
|
+
* controversial content, inappropriate associations, and reputation risks.
|
|
14
|
+
*
|
|
15
|
+
* **Pricing**: 2.0 credits per creator analyzed
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const response = await client.brandSafety.analyzeCreators({
|
|
20
|
+
* creator_ids: [
|
|
21
|
+
* '123e4567-e89b-12d3-a456-426614174000',
|
|
22
|
+
* '987fcdeb-51a2-43d1-9f12-345678901234',
|
|
23
|
+
* ],
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
analyzeCreators(
|
|
28
|
+
body: BrandSafetyAnalyzeCreatorsParams,
|
|
29
|
+
options?: RequestOptions,
|
|
30
|
+
): APIPromise<BrandSafetyAnalyzeCreatorsResponse> {
|
|
31
|
+
return this._client.post('/v1/brand-safety/creators', { body, ...options });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Analyze individual posts for brand safety risks.
|
|
36
|
+
*
|
|
37
|
+
* This endpoint evaluates specific posts for potential brand safety issues.
|
|
38
|
+
*
|
|
39
|
+
* **Pricing**: 0.5 credits per post analyzed
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const response = await client.brandSafety.analyzePosts({
|
|
44
|
+
* posts: [
|
|
45
|
+
* {
|
|
46
|
+
* platform: 'instagram',
|
|
47
|
+
* url: 'https://www.instagram.com/p/Cx123Sample/',
|
|
48
|
+
* },
|
|
49
|
+
* {
|
|
50
|
+
* platform: 'instagram',
|
|
51
|
+
* post_id: '9876543210987654321',
|
|
52
|
+
* },
|
|
53
|
+
* ],
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
analyzePosts(
|
|
58
|
+
body: BrandSafetyAnalyzePostsParams,
|
|
59
|
+
options?: RequestOptions,
|
|
60
|
+
): APIPromise<BrandSafetyAnalyzePostsResponse> {
|
|
61
|
+
return this._client.post('/v1/brand-safety/posts', { body, ...options });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Analyze social media profiles for brand safety risks.
|
|
66
|
+
*
|
|
67
|
+
* This endpoint evaluates profiles by username for potential brand safety issues.
|
|
68
|
+
*
|
|
69
|
+
* **Pricing**: 2.0 credits per profile analyzed
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const response = await client.brandSafety.analyzeProfiles({
|
|
74
|
+
* profiles: [
|
|
75
|
+
* { platform: 'instagram', username: 'wellnessdaily' },
|
|
76
|
+
* ],
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
analyzeProfiles(
|
|
81
|
+
body: BrandSafetyAnalyzeProfilesParams,
|
|
82
|
+
options?: RequestOptions,
|
|
83
|
+
): APIPromise<BrandSafetyAnalyzeProfilesResponse> {
|
|
84
|
+
return this._client.post('/v1/brand-safety/profiles', { body, ...options });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Brand safety analysis results
|
|
90
|
+
*/
|
|
91
|
+
export interface BrandSafetyAnalysis {
|
|
92
|
+
/**
|
|
93
|
+
* Specific safety concerns detected. Empty array = no issues found.
|
|
94
|
+
*/
|
|
95
|
+
flags: Array<BrandSafetyFlag>;
|
|
96
|
+
|
|
97
|
+
metadata: BrandSafetyAnalysis.Metadata;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether the analysis completed successfully
|
|
101
|
+
*/
|
|
102
|
+
ok: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Confidence score (0-1) for the rating. >0.8 = high confidence.
|
|
106
|
+
*/
|
|
107
|
+
overall_confidence: number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Brand safety rating. A = safe (no risks), B = moderate concerns, C = significant
|
|
111
|
+
* risks.
|
|
112
|
+
*/
|
|
113
|
+
rating: 'A' | 'B' | 'C';
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Detailed reasoning explaining the analysis result. Includes context about
|
|
117
|
+
* content analyzed and decision factors.
|
|
118
|
+
*/
|
|
119
|
+
reasoning: string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Human-readable summary of the assessment.
|
|
123
|
+
*/
|
|
124
|
+
summary: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export namespace BrandSafetyAnalysis {
|
|
128
|
+
export interface Metadata {
|
|
129
|
+
/**
|
|
130
|
+
* When the analysis was performed
|
|
131
|
+
*/
|
|
132
|
+
analysis_date: string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Information about the content that was analyzed
|
|
136
|
+
*/
|
|
137
|
+
content_analyzed: Metadata.ContentAnalyzed;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Version of the AI model used for analysis
|
|
141
|
+
*/
|
|
142
|
+
model_version: string;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Processing time in milliseconds
|
|
146
|
+
*/
|
|
147
|
+
processing_time_ms: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export namespace Metadata {
|
|
151
|
+
/**
|
|
152
|
+
* Information about the content that was analyzed
|
|
153
|
+
*/
|
|
154
|
+
export interface ContentAnalyzed {
|
|
155
|
+
/**
|
|
156
|
+
* Number of posts analyzed (for profile/creator analysis)
|
|
157
|
+
*/
|
|
158
|
+
posts_count?: number;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Length of text content analyzed
|
|
162
|
+
*/
|
|
163
|
+
text_length?: number;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Individual brand safety flag with detailed information
|
|
170
|
+
*/
|
|
171
|
+
export interface BrandSafetyFlag {
|
|
172
|
+
/**
|
|
173
|
+
* Confidence score for this specific flag (0-1). Higher values indicate greater
|
|
174
|
+
* certainty about this concern.
|
|
175
|
+
*/
|
|
176
|
+
confidence: number;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Human-readable description explaining the concern. Provides context about what
|
|
180
|
+
* was detected.
|
|
181
|
+
*/
|
|
182
|
+
description: string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Severity level of the concern:
|
|
186
|
+
*
|
|
187
|
+
* - `low`: Minor issue, may be acceptable for some brands
|
|
188
|
+
* - `medium`: Moderate concern, evaluate based on brand guidelines
|
|
189
|
+
* - `high`: Significant risk, likely unsuitable for most brands
|
|
190
|
+
*/
|
|
191
|
+
severity: 'low' | 'medium' | 'high';
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Category of brand safety concern detected:
|
|
195
|
+
*
|
|
196
|
+
* - `adult_sexual_content`: Sexually explicit or suggestive content
|
|
197
|
+
* - `profanity_strong_language`: Profanity or offensive language
|
|
198
|
+
* - `drugs_alcohol_tobacco`: Drug, alcohol, or tobacco-related content
|
|
199
|
+
* - `violence_weapons`: Violent content or weapon references
|
|
200
|
+
* - `hate_discrimination`: Hate speech or discriminatory content
|
|
201
|
+
* - `political_social_issues`: Politically divisive or controversial topics
|
|
202
|
+
* - `misinformation_conspiracy`: Misinformation or conspiracy theories
|
|
203
|
+
* - `misc`: Other brand safety concerns
|
|
204
|
+
*/
|
|
205
|
+
type:
|
|
206
|
+
| 'adult_sexual_content'
|
|
207
|
+
| 'profanity_strong_language'
|
|
208
|
+
| 'drugs_alcohol_tobacco'
|
|
209
|
+
| 'violence_weapons'
|
|
210
|
+
| 'hate_discrimination'
|
|
211
|
+
| 'political_social_issues'
|
|
212
|
+
| 'misinformation_conspiracy'
|
|
213
|
+
| 'misc';
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Specific examples or evidence that triggered this flag. May include post
|
|
217
|
+
* excerpts or contextual information.
|
|
218
|
+
*/
|
|
219
|
+
evidence?: Array<string>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Result of brand safety analysis
|
|
224
|
+
*/
|
|
225
|
+
export interface BrandSafetyResult {
|
|
226
|
+
/**
|
|
227
|
+
* Unique identifier for the analysis result
|
|
228
|
+
*/
|
|
229
|
+
id: string;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Brand safety analysis results
|
|
233
|
+
*/
|
|
234
|
+
analysis: BrandSafetyAnalysis;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface BrandSafetyAnalyzeCreatorsResponse {
|
|
238
|
+
results?: Array<BrandSafetyResult>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface BrandSafetyAnalyzePostsResponse {
|
|
242
|
+
results?: Array<BrandSafetyResult>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface BrandSafetyAnalyzeProfilesResponse {
|
|
246
|
+
results?: Array<BrandSafetyResult>;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface BrandSafetyAnalyzeCreatorsParams {
|
|
250
|
+
/**
|
|
251
|
+
* Creator IDs to analyze
|
|
252
|
+
*/
|
|
253
|
+
creator_ids: Array<string>;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface BrandSafetyAnalyzePostsParams {
|
|
257
|
+
posts: Array<
|
|
258
|
+
BrandSafetyAnalyzePostsParams.BrandSafetyPostByURL | BrandSafetyAnalyzePostsParams.BrandSafetyPostByID
|
|
259
|
+
>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export namespace BrandSafetyAnalyzePostsParams {
|
|
263
|
+
export interface BrandSafetyPostByURL {
|
|
264
|
+
/**
|
|
265
|
+
* Social media platform hosting the post
|
|
266
|
+
*/
|
|
267
|
+
platform: 'instagram';
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* URL of the post to scan
|
|
271
|
+
*/
|
|
272
|
+
url: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface BrandSafetyPostByID {
|
|
276
|
+
/**
|
|
277
|
+
* Social media platform hosting the post
|
|
278
|
+
*/
|
|
279
|
+
platform: 'instagram';
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Platform-specific post identifier
|
|
283
|
+
*/
|
|
284
|
+
post_id: string;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface BrandSafetyAnalyzeProfilesParams {
|
|
289
|
+
profiles: Array<ProfilesAPI.CreatorReferenceByHandle>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export declare namespace BrandSafety {
|
|
293
|
+
export {
|
|
294
|
+
type BrandSafetyAnalysis as BrandSafetyAnalysis,
|
|
295
|
+
type BrandSafetyFlag as BrandSafetyFlag,
|
|
296
|
+
type BrandSafetyResult as BrandSafetyResult,
|
|
297
|
+
type BrandSafetyAnalyzeCreatorsResponse as BrandSafetyAnalyzeCreatorsResponse,
|
|
298
|
+
type BrandSafetyAnalyzePostsResponse as BrandSafetyAnalyzePostsResponse,
|
|
299
|
+
type BrandSafetyAnalyzeProfilesResponse as BrandSafetyAnalyzeProfilesResponse,
|
|
300
|
+
type BrandSafetyAnalyzeCreatorsParams as BrandSafetyAnalyzeCreatorsParams,
|
|
301
|
+
type BrandSafetyAnalyzePostsParams as BrandSafetyAnalyzePostsParams,
|
|
302
|
+
type BrandSafetyAnalyzeProfilesParams as BrandSafetyAnalyzeProfilesParams,
|
|
303
|
+
};
|
|
304
|
+
}
|