sg-widgets-core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +90 -68
- package/dist/index.mjs +191 -5
- package/dist/mock.d.mts +39 -1
- package/dist/mock.mjs +267 -2
- package/dist/{client-CP9sWEVZ.d.mts → proxy-handler-C6XB6gss.d.mts} +311 -65
- package/dist/{client-izKszX7l.mjs → schema-write-D_WfMYW8.mjs} +384 -2
- package/package.json +1 -1
|
@@ -38,70 +38,6 @@ declare function isLinkType(dataType: string): boolean;
|
|
|
38
38
|
declare function isNumericType(dataType: string): boolean;
|
|
39
39
|
declare function isTemporalType(dataType: string): boolean;
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region src/filter.d.ts
|
|
42
|
-
type LogicalOperator = 'and' | 'or';
|
|
43
|
-
interface EntityRef {
|
|
44
|
-
type: string;
|
|
45
|
-
id: number;
|
|
46
|
-
/** `cached_display_name` of the target when known. Never sent to the API. */
|
|
47
|
-
name?: string;
|
|
48
|
-
}
|
|
49
|
-
type Scalar = string | number | boolean | null | EntityRef;
|
|
50
|
-
type ConditionValue = Scalar | Scalar[] | [Scalar, Scalar] | [number, TimeUnit];
|
|
51
|
-
interface FilterCondition {
|
|
52
|
-
kind: 'condition';
|
|
53
|
-
/** Dotted path such as `entity.Shot.code`. */
|
|
54
|
-
path: string;
|
|
55
|
-
operator: Operator;
|
|
56
|
-
value: ConditionValue;
|
|
57
|
-
}
|
|
58
|
-
interface FilterGroup {
|
|
59
|
-
kind: 'group';
|
|
60
|
-
logicalOperator: LogicalOperator;
|
|
61
|
-
conditions: FilterNode[];
|
|
62
|
-
}
|
|
63
|
-
type FilterNode = FilterGroup | FilterCondition;
|
|
64
|
-
/** Wire shapes. */
|
|
65
|
-
type WireCondition = [string, Operator, unknown];
|
|
66
|
-
interface WireGroup {
|
|
67
|
-
logical_operator: LogicalOperator;
|
|
68
|
-
conditions: Array<WireCondition | WireGroup>;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* What one type's entry in `_text_search`'s `entity_types` map accepts: a filter
|
|
72
|
-
* array, or a group this converts to one.
|
|
73
|
-
*/
|
|
74
|
-
type TextSearchFilter = WireGroup | WireCondition[] | null | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* The filter array `entity_types` wants, `[]` for no filter
|
|
77
|
-
* (post_entity_text_search). The array form is `and` only and cannot express a
|
|
78
|
-
* nested group, so one is refused here rather than sent and guessed at.
|
|
79
|
-
*/
|
|
80
|
-
declare function toFilterArray(filter: TextSearchFilter): WireCondition[];
|
|
81
|
-
declare function group(logicalOperator: LogicalOperator, conditions?: FilterNode[]): FilterGroup;
|
|
82
|
-
declare function condition(path: string, operator: Operator, value: ConditionValue): FilterCondition;
|
|
83
|
-
declare function emptyFilter(): FilterGroup;
|
|
84
|
-
/**
|
|
85
|
-
* A condition is blank when it has no path, or when its operator needs a value
|
|
86
|
-
* and none was given. Blank conditions are dropped on serialisation rather than
|
|
87
|
-
* sent as a degenerate filter.
|
|
88
|
-
*/
|
|
89
|
-
declare function isBlankCondition(c: FilterCondition): boolean;
|
|
90
|
-
/** True when serialisation would produce no conditions at all. */
|
|
91
|
-
declare function isEmptyFilter(node: FilterNode): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Serialise a tree to the `api3_hash` `filters` value. Blank conditions and
|
|
94
|
-
* groups that end up empty are dropped. Returns `null` when nothing remains,
|
|
95
|
-
* so callers can omit `filters` rather than send `[]` (which matches every
|
|
96
|
-
* row on the site).
|
|
97
|
-
*/
|
|
98
|
-
declare function toApi3Hash(node: FilterNode): WireGroup | null;
|
|
99
|
-
/** Parse a wire group (or a flat `api3_array` list) back into the editor tree. */
|
|
100
|
-
declare function fromWire(wire: WireGroup | WireCondition[]): FilterGroup;
|
|
101
|
-
/** Depth-first walk, useful for collecting referenced paths or validating against a schema. */
|
|
102
|
-
declare function walk(node: FilterNode): Generator<FilterNode>;
|
|
103
|
-
declare function referencedPaths(node: FilterNode): string[];
|
|
104
|
-
//#endregion
|
|
105
41
|
//#region src/schema.d.ts
|
|
106
42
|
/** One property as the API returns it. */
|
|
107
43
|
interface RawProperty<T = unknown> {
|
|
@@ -115,6 +51,10 @@ interface RawFieldSchema {
|
|
|
115
51
|
editable: RawProperty<boolean>;
|
|
116
52
|
mandatory: RawProperty<boolean>;
|
|
117
53
|
unique: RawProperty<boolean>;
|
|
54
|
+
/** At the top level beside `name`, not under `properties` (116_field_settings_create_update). */
|
|
55
|
+
description?: RawProperty<string>;
|
|
56
|
+
/** At the top level too (002_schema). */
|
|
57
|
+
custom_metadata?: RawProperty<string>;
|
|
118
58
|
/** `editable` here says whether the site may hide the field (056_stock_vs_custom_field). */
|
|
119
59
|
visible?: RawProperty<boolean>;
|
|
120
60
|
properties: Record<string, RawProperty<unknown>>;
|
|
@@ -369,6 +309,70 @@ type StatusGlyph = {
|
|
|
369
309
|
/** The glyph a status draws, from its icon and whichever sprite can serve it. */
|
|
370
310
|
declare function statusGlyph(status: Pick<StatusRecord, 'icon'> | null | undefined, siteUrl?: string): StatusGlyph;
|
|
371
311
|
//#endregion
|
|
312
|
+
//#region src/filter.d.ts
|
|
313
|
+
type LogicalOperator = 'and' | 'or';
|
|
314
|
+
interface EntityRef {
|
|
315
|
+
type: string;
|
|
316
|
+
id: number;
|
|
317
|
+
/** `cached_display_name` of the target when known. Never sent to the API. */
|
|
318
|
+
name?: string;
|
|
319
|
+
}
|
|
320
|
+
type Scalar = string | number | boolean | null | EntityRef;
|
|
321
|
+
type ConditionValue = Scalar | Scalar[] | [Scalar, Scalar] | [number, TimeUnit];
|
|
322
|
+
interface FilterCondition {
|
|
323
|
+
kind: 'condition';
|
|
324
|
+
/** Dotted path such as `entity.Shot.code`. */
|
|
325
|
+
path: string;
|
|
326
|
+
operator: Operator;
|
|
327
|
+
value: ConditionValue;
|
|
328
|
+
}
|
|
329
|
+
interface FilterGroup {
|
|
330
|
+
kind: 'group';
|
|
331
|
+
logicalOperator: LogicalOperator;
|
|
332
|
+
conditions: FilterNode[];
|
|
333
|
+
}
|
|
334
|
+
type FilterNode = FilterGroup | FilterCondition;
|
|
335
|
+
/** Wire shapes. */
|
|
336
|
+
type WireCondition = [string, Operator, unknown];
|
|
337
|
+
interface WireGroup {
|
|
338
|
+
logical_operator: LogicalOperator;
|
|
339
|
+
conditions: Array<WireCondition | WireGroup>;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* What one type's entry in `_text_search`'s `entity_types` map accepts: a filter
|
|
343
|
+
* array, or a group this converts to one.
|
|
344
|
+
*/
|
|
345
|
+
type TextSearchFilter = WireGroup | WireCondition[] | null | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* The filter array `entity_types` wants, `[]` for no filter
|
|
348
|
+
* (post_entity_text_search). The array form is `and` only and cannot express a
|
|
349
|
+
* nested group, so one is refused here rather than sent and guessed at.
|
|
350
|
+
*/
|
|
351
|
+
declare function toFilterArray(filter: TextSearchFilter): WireCondition[];
|
|
352
|
+
declare function group(logicalOperator: LogicalOperator, conditions?: FilterNode[]): FilterGroup;
|
|
353
|
+
declare function condition(path: string, operator: Operator, value: ConditionValue): FilterCondition;
|
|
354
|
+
declare function emptyFilter(): FilterGroup;
|
|
355
|
+
/**
|
|
356
|
+
* A condition is blank when it has no path, or when its operator needs a value
|
|
357
|
+
* and none was given. Blank conditions are dropped on serialisation rather than
|
|
358
|
+
* sent as a degenerate filter.
|
|
359
|
+
*/
|
|
360
|
+
declare function isBlankCondition(c: FilterCondition): boolean;
|
|
361
|
+
/** True when serialisation would produce no conditions at all. */
|
|
362
|
+
declare function isEmptyFilter(node: FilterNode): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Serialise a tree to the `api3_hash` `filters` value. Blank conditions and
|
|
365
|
+
* groups that end up empty are dropped. Returns `null` when nothing remains,
|
|
366
|
+
* so callers can omit `filters` rather than send `[]` (which matches every
|
|
367
|
+
* row on the site).
|
|
368
|
+
*/
|
|
369
|
+
declare function toApi3Hash(node: FilterNode): WireGroup | null;
|
|
370
|
+
/** Parse a wire group (or a flat `api3_array` list) back into the editor tree. */
|
|
371
|
+
declare function fromWire(wire: WireGroup | WireCondition[]): FilterGroup;
|
|
372
|
+
/** Depth-first walk, useful for collecting referenced paths or validating against a schema. */
|
|
373
|
+
declare function walk(node: FilterNode): Generator<FilterNode>;
|
|
374
|
+
declare function referencedPaths(node: FilterNode): string[];
|
|
375
|
+
//#endregion
|
|
372
376
|
//#region src/client.d.ts
|
|
373
377
|
interface SearchOptions {
|
|
374
378
|
filters?: WireGroup | null;
|
|
@@ -842,4 +846,246 @@ declare class RestClient implements SgClient {
|
|
|
842
846
|
/** One `_search` row of `EventLogEntry`, with `meta` decoded as the API returns it. */
|
|
843
847
|
declare function normalizeEventLogEntry(row: EntityRow): EventLogEntry;
|
|
844
848
|
//#endregion
|
|
845
|
-
|
|
849
|
+
//#region src/proxy-client.d.ts
|
|
850
|
+
interface ProxyClientOptions {
|
|
851
|
+
/** Where the endpoints live, e.g. `/sg` or `https://app.example.com/api/sg`. */
|
|
852
|
+
basePath: string;
|
|
853
|
+
fetch?: typeof fetch;
|
|
854
|
+
/** Extra request headers. Called per request, so a caller can rotate a CSRF or auth header. */
|
|
855
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
856
|
+
}
|
|
857
|
+
declare class ProxyClient implements SgClient {
|
|
858
|
+
private readonly options;
|
|
859
|
+
private readonly base;
|
|
860
|
+
private readonly fetchFn;
|
|
861
|
+
constructor(options: ProxyClientOptions);
|
|
862
|
+
private post;
|
|
863
|
+
entityTypes(): Promise<EntityTypeInfo[]>;
|
|
864
|
+
fields(entityType: string, projectId?: number): Promise<Record<string, FieldSchema>>;
|
|
865
|
+
fieldWithProject(entityType: string, field: string, projectId: number): Promise<FieldSchema>;
|
|
866
|
+
search(entityType: string, options: SearchOptions): Promise<SearchResult>;
|
|
867
|
+
read(entityType: string, id: number, options?: ReadOptions): Promise<EntityRow>;
|
|
868
|
+
textSearch(text: string, entityTypes: Record<string, TextSearchFilter>, page?: {
|
|
869
|
+
size?: number;
|
|
870
|
+
number?: number;
|
|
871
|
+
}): Promise<TextSearchRow[]>;
|
|
872
|
+
statuses(): Promise<StatusRecord[]>;
|
|
873
|
+
create(entityType: string, body: Record<string, unknown>): Promise<EntityRow>;
|
|
874
|
+
delete(entityType: string, id: number): Promise<void>;
|
|
875
|
+
revive(entityType: string, id: number): Promise<boolean>;
|
|
876
|
+
batch(requests: BatchRequest[]): Promise<BatchResult[]>;
|
|
877
|
+
/** The bytes cross the protocol base64-encoded; the handler runs the three calls. */
|
|
878
|
+
upload(entityType: string, id: number, file: UploadFile): Promise<UploadResult>;
|
|
879
|
+
update(entityType: string, id: number, patch: Record<string, unknown>): Promise<EntityRow>;
|
|
880
|
+
hierarchySearch(rootPath: string, entity: EntityRef): Promise<HierarchyPath[]>;
|
|
881
|
+
hierarchyExpand(path: string): Promise<HierarchyNode>;
|
|
882
|
+
summarize(entityType: string, options?: SummarizeOptions): Promise<SummarizeResult>;
|
|
883
|
+
threadContents(noteId: number, entityFields?: Record<string, string[]>): Promise<ThreadRow[]>;
|
|
884
|
+
eventLog(options?: EventLogOptions): Promise<EventLogResult>;
|
|
885
|
+
following(userId: number, options?: FollowingOptions): Promise<EntityRef[]>;
|
|
886
|
+
}
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/schema-write.d.ts
|
|
889
|
+
/** One setting of a field, in the shape a create and an update take. */
|
|
890
|
+
interface SchemaProperty {
|
|
891
|
+
property_name: string;
|
|
892
|
+
value: unknown;
|
|
893
|
+
}
|
|
894
|
+
/** Settings as the API's list, or as a record turned into one in key order. */
|
|
895
|
+
type SchemaProperties = SchemaProperty[] | Record<string, unknown>;
|
|
896
|
+
declare function toSchemaProperties(properties?: SchemaProperties): SchemaProperty[];
|
|
897
|
+
interface CreateFieldInput {
|
|
898
|
+
/**
|
|
899
|
+
* `text float number date date_time list url duration percent footage` take
|
|
900
|
+
* nothing else. `checkbox` needs `default_value` and `status_list` its
|
|
901
|
+
* `valid_values`; `entity` needs `valid_types`, one type or several, and
|
|
902
|
+
* `multi_entity` exactly one; `color`, `image` and `calculated` are refused
|
|
903
|
+
* (019_create_fields, 116_field_settings_create_update).
|
|
904
|
+
*/
|
|
905
|
+
dataType: string;
|
|
906
|
+
/** Sent as the `name` property. The server derives the programmatic name from it. */
|
|
907
|
+
displayName: string;
|
|
908
|
+
/** Every other setting. A `name` here is sent after `displayName`. */
|
|
909
|
+
properties?: SchemaProperties;
|
|
910
|
+
}
|
|
911
|
+
interface CreatedField {
|
|
912
|
+
/** The programmatic name the server assigned: the last segment of `links.self`. It is not in the body. */
|
|
913
|
+
name: string;
|
|
914
|
+
/** `links.self` as it came. */
|
|
915
|
+
self: string;
|
|
916
|
+
/** The response's `data`, verbatim. */
|
|
917
|
+
raw: Record<string, unknown> | null;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* What a read of one field answered. `raw` is the wrapped record verbatim, each
|
|
921
|
+
* value beside its `editable` flag, fit to store as a snapshot.
|
|
922
|
+
*/
|
|
923
|
+
type FieldReadResult = {
|
|
924
|
+
status: 'found';
|
|
925
|
+
field: FieldSchema;
|
|
926
|
+
raw: RawFieldSchema;
|
|
927
|
+
} |
|
|
928
|
+
/** 404 `Field '<Type>.<field>' does not exist.` A retired field and a name never used read the same (040_field_revive). */
|
|
929
|
+
{
|
|
930
|
+
status: 'missing';
|
|
931
|
+
message: string;
|
|
932
|
+
} |
|
|
933
|
+
/** 200 with `data: null`: the row answers the field and the schema leaves it out (068_note_read_state). */
|
|
934
|
+
{
|
|
935
|
+
status: 'undeclared';
|
|
936
|
+
};
|
|
937
|
+
/** `revived: false` carries the refusal as the server sent it. */
|
|
938
|
+
type ReviveFieldResult = {
|
|
939
|
+
revived: true;
|
|
940
|
+
} | {
|
|
941
|
+
revived: false;
|
|
942
|
+
status: number;
|
|
943
|
+
message: string;
|
|
944
|
+
};
|
|
945
|
+
interface SchemaClient {
|
|
946
|
+
/**
|
|
947
|
+
* One field of a type, at site scope or at a project's. Only `hidden_values`
|
|
948
|
+
* is measured to differ by project (009_status_lists).
|
|
949
|
+
*
|
|
950
|
+
* A field that does not exist is the `missing` result, not a rejection. Every
|
|
951
|
+
* other failure rejects, a type the site does not have included.
|
|
952
|
+
*/
|
|
953
|
+
readField(entityType: string, field: string, projectId?: number): Promise<FieldReadResult>;
|
|
954
|
+
/** Every field of a type as the wrapped records, verbatim. About 48KB a type (get_schema_type_fields). */
|
|
955
|
+
readRawFields(entityType: string, projectId?: number): Promise<Record<string, RawFieldSchema>>;
|
|
956
|
+
/**
|
|
957
|
+
* Create a field and answer the name the server gave it.
|
|
958
|
+
*
|
|
959
|
+
* A display name already in use is a 201 for a suffixed field, `<name>_1`, with
|
|
960
|
+
* no warning, and a display name that starts `sg_` is prefixed again: compare
|
|
961
|
+
* the answered name with the wanted one, and read the type's fields before
|
|
962
|
+
* creating (019_create_fields, reports/006). A name a retired field holds is
|
|
963
|
+
* refused at 400; `reviveField` is the way back (040_field_revive).
|
|
964
|
+
*/
|
|
965
|
+
createField(entityType: string, input: CreateFieldInput): Promise<CreatedField>;
|
|
966
|
+
/**
|
|
967
|
+
* Change a field's settings, at site scope or at a project's, and answer the
|
|
968
|
+
* record the server sent back.
|
|
969
|
+
*
|
|
970
|
+
* The answer is not proof: a `data_type` sent beside `properties` is a 200 that
|
|
971
|
+
* changes nothing. Read the field back (put_schema_type_fields_field). A
|
|
972
|
+
* property the update does not take is a 400 that lists the ones it does;
|
|
973
|
+
* `hidden_values` is not one (114_schema_admin_recheck).
|
|
974
|
+
*/
|
|
975
|
+
updateField(entityType: string, field: string, properties: SchemaProperties, projectId?: number): Promise<RawFieldSchema | null>;
|
|
976
|
+
/**
|
|
977
|
+
* Retire a field. Its programmatic name is spent: the same name does not create
|
|
978
|
+
* again, only revive, and no call frees it (delete_schema_type_fields_field). A
|
|
979
|
+
* field already retired rejects with a 404 (114_schema_admin_recheck).
|
|
980
|
+
*/
|
|
981
|
+
retireField(entityType: string, field: string): Promise<void>;
|
|
982
|
+
/**
|
|
983
|
+
* Bring a retired field back. It returns at the data type it was created at,
|
|
984
|
+
* so read it back (040_field_revive).
|
|
985
|
+
*
|
|
986
|
+
* A 204 is `revived: true`. A 4xx other than 401 and 403 is `revived: false`
|
|
987
|
+
* with the server's status and message; those two and everything else reject.
|
|
988
|
+
* The answer for a name with nothing retired behind it is not measured.
|
|
989
|
+
*/
|
|
990
|
+
reviveField(entityType: string, field: string): Promise<ReviveFieldResult>;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* A refusal from a schema call, as the server sent it: `status` and `body` whole,
|
|
994
|
+
* and the first error's `code`, `title`, `detail` and `source` lifted out.
|
|
995
|
+
*
|
|
996
|
+
* `message` is the `detail` where there is one and the `title` otherwise, followed
|
|
997
|
+
* by whatever only the `source` says. A 404 is titled `Not Found` and says which
|
|
998
|
+
* name is wrong in its `detail` (002_schema).
|
|
999
|
+
*/
|
|
1000
|
+
declare class SchemaApiError extends SgApiError {
|
|
1001
|
+
readonly code: number | null;
|
|
1002
|
+
readonly title: string | null;
|
|
1003
|
+
readonly detail: string | null;
|
|
1004
|
+
readonly source: unknown;
|
|
1005
|
+
constructor(status: number, body: unknown, message?: string);
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* A wrapped record as a `FieldSchema`. The record is left as it came; a key the
|
|
1009
|
+
* response leaves out is read as its default, with the type taken from the path.
|
|
1010
|
+
*/
|
|
1011
|
+
declare function fieldFromRaw(entityType: string, name: string, raw: RawFieldSchema): FieldSchema;
|
|
1012
|
+
declare class RestSchemaClient implements SchemaClient {
|
|
1013
|
+
private readonly options;
|
|
1014
|
+
private readonly base;
|
|
1015
|
+
private readonly fetchFn;
|
|
1016
|
+
constructor(options: RestClientOptions);
|
|
1017
|
+
private request;
|
|
1018
|
+
readField(entityType: string, field: string, projectId?: number): Promise<FieldReadResult>;
|
|
1019
|
+
readRawFields(entityType: string, projectId?: number): Promise<Record<string, RawFieldSchema>>;
|
|
1020
|
+
createField(entityType: string, input: CreateFieldInput): Promise<CreatedField>;
|
|
1021
|
+
updateField(entityType: string, field: string, properties: SchemaProperties, projectId?: number): Promise<RawFieldSchema | null>;
|
|
1022
|
+
retireField(entityType: string, field: string): Promise<void>;
|
|
1023
|
+
reviveField(entityType: string, field: string): Promise<ReviveFieldResult>;
|
|
1024
|
+
}
|
|
1025
|
+
/** The schema methods the proxy protocol carries, one POST each, beside `PROXY_METHODS`. */
|
|
1026
|
+
declare const SCHEMA_PROXY_METHODS: readonly ['readField', 'readRawFields', 'createField', 'updateField', 'retireField', 'reviveField'];
|
|
1027
|
+
type SchemaProxyMethod = (typeof SCHEMA_PROXY_METHODS)[number];
|
|
1028
|
+
declare function isSchemaProxyMethod(value: string): value is SchemaProxyMethod;
|
|
1029
|
+
/**
|
|
1030
|
+
* The server half of `ProxySchemaClient`, in the protocol of `createProxyHandler`.
|
|
1031
|
+
* It answers 404 to a method that is not a schema one, so a host routes on
|
|
1032
|
+
* `isSchemaProxyMethod`, or hands the schema client to `createProxyHandler`.
|
|
1033
|
+
*
|
|
1034
|
+
* These calls change the site's schema for everyone: expose them only to the
|
|
1035
|
+
* people who may.
|
|
1036
|
+
*/
|
|
1037
|
+
declare function createSchemaProxyHandler(client: SchemaClient): ProxyHandler;
|
|
1038
|
+
/** A `SchemaClient` over the host app's own endpoints: one POST per method under `basePath`. */
|
|
1039
|
+
declare class ProxySchemaClient implements SchemaClient {
|
|
1040
|
+
private readonly options;
|
|
1041
|
+
private readonly base;
|
|
1042
|
+
private readonly fetchFn;
|
|
1043
|
+
constructor(options: ProxyClientOptions);
|
|
1044
|
+
private post;
|
|
1045
|
+
readField(entityType: string, field: string, projectId?: number): Promise<FieldReadResult>;
|
|
1046
|
+
readRawFields(entityType: string, projectId?: number): Promise<Record<string, RawFieldSchema>>;
|
|
1047
|
+
createField(entityType: string, input: CreateFieldInput): Promise<CreatedField>;
|
|
1048
|
+
updateField(entityType: string, field: string, properties: SchemaProperties, projectId?: number): Promise<RawFieldSchema | null>;
|
|
1049
|
+
retireField(entityType: string, field: string): Promise<void>;
|
|
1050
|
+
reviveField(entityType: string, field: string): Promise<ReviveFieldResult>;
|
|
1051
|
+
}
|
|
1052
|
+
//#endregion
|
|
1053
|
+
//#region src/proxy-handler.d.ts
|
|
1054
|
+
/** The methods the protocol carries, one POST each. */
|
|
1055
|
+
declare const PROXY_METHODS: readonly ['entityTypes', 'fields', 'fieldWithProject', 'search', 'read', 'textSearch', 'statuses', 'create', 'update', 'upload', 'hierarchyExpand', 'hierarchySearch', 'summarize', 'threadContents', 'eventLog', 'following', 'delete', 'revive', 'batch'];
|
|
1056
|
+
type ProxyMethod = (typeof PROXY_METHODS)[number];
|
|
1057
|
+
/** An error as it crosses the wire. `ProxyClient` rebuilds an `SgApiError` from it. */
|
|
1058
|
+
interface ProxyError {
|
|
1059
|
+
status: number;
|
|
1060
|
+
message: string;
|
|
1061
|
+
body: unknown;
|
|
1062
|
+
}
|
|
1063
|
+
type ProxyBody = {
|
|
1064
|
+
data: unknown;
|
|
1065
|
+
} | {
|
|
1066
|
+
error: ProxyError;
|
|
1067
|
+
};
|
|
1068
|
+
interface ProxyResult {
|
|
1069
|
+
/** HTTP status the wrapper writes. */
|
|
1070
|
+
status: number;
|
|
1071
|
+
body: ProxyBody;
|
|
1072
|
+
}
|
|
1073
|
+
type ProxyHandler = (method: string, body: unknown) => Promise<ProxyResult>;
|
|
1074
|
+
declare function isProxyMethod(value: string): value is ProxyMethod;
|
|
1075
|
+
/**
|
|
1076
|
+
* Bytes as base64. The protocol is one JSON object per call, so an upload's bytes
|
|
1077
|
+
* cross it encoded and are decoded here.
|
|
1078
|
+
*/
|
|
1079
|
+
declare function bytesToBase64(bytes: Uint8Array): string;
|
|
1080
|
+
declare function base64ToBytes(value: string): Uint8Array;
|
|
1081
|
+
interface ProxyHandlerOptions {
|
|
1082
|
+
/**
|
|
1083
|
+
* Also carry `SCHEMA_PROXY_METHODS` to this client. Left out, they are a 404:
|
|
1084
|
+
* a schema write changes the site for everyone, so a host opts in.
|
|
1085
|
+
*/
|
|
1086
|
+
schema?: SchemaClient;
|
|
1087
|
+
}
|
|
1088
|
+
/** Wraps a client so a host app can expose it over its own HTTP endpoints. */
|
|
1089
|
+
declare function createProxyHandler(client: SgClient, options?: ProxyHandlerOptions): ProxyHandler;
|
|
1090
|
+
//#endregion
|
|
1091
|
+
export { SummaryField as $, STOCK_SPRITE_PATH as $t, BatchRequest as A, isFilterable as An, toApi3Hash as At, HierarchyPath as B, intersectStatuses as Bt, SchemaProxyMethod as C, OPERATORS_BY_TYPE as Cn, condition as Ct, toSchemaProperties as D, VALUE_SHAPE as Dn, isBlankCondition as Dt, isSchemaProxyMethod as E, TimeUnit as En, group as Et, EventLogEntry as F, operatorsFor as Fn, StatusIcon as Ft, RestClient as G, statusLabel as Gt, RawBatchRow as H, relativeLuminance as Ht, EventLogOptions as I, supportsOperator as In, StatusOption as It, SearchResult as J, NATIVE_STATUSES as Jt, RestClientOptions as K, statusPaint as Kt, EventLogResult as L, StatusPaint as Lt, EVENT_LOG_FIELDS as M, isNumericType as Mn, walk as Mt, EntityRow as N, isOperator as Nn, Rgb as Nt, ProxyClient as O, ValueShape as On, isEmptyFilter as Ot, EntityTypeInfo as P, isTemporalType as Pn, StatusGlyph as Pt, SummarizeResult as Q, STOCK_ICON_KEYS as Qt, FollowingOptions as R, StatusRecord as Rt, SchemaProperty as S, OPERATORS as Sn, WireGroup as St, fieldFromRaw as T, TIME_UNITS as Tn, fromWire as Tt, RawHierarchyNode as U, rgbToCss as Ut, HierarchyRef as V, parseBgColor as Vt, ReadOptions as W, statusGlyph as Wt, SgClient as X, STOCK_ICON_CELLS as Xt, SgApiError as Y, NativeStatus as Yt, SummarizeOptions as Z, STOCK_ICON_DATA_URLS as Zt, ReviveFieldResult as _, statusFieldNameFor as _n, FilterNode as _t, ProxyHandlerOptions as a, stockIconSource as an, ThreadRow as at, SchemaClient as b, DataType as bn, TextSearchFilter as bt, base64ToBytes as c, FieldSchema as cn, batchResults as ct, isProxyMethod as d, RawProperty as dn, normalizeEventLogEntry as dt, SpriteCell as en, SummaryGroup as et, CreateFieldInput as f, displayNameOf as fn, normalizeHierarchyNode as ft, RestSchemaClient as g, statusFieldFor as gn, FilterGroup as gt, ProxySchemaClient as h, normalizeFields as hn, FilterCondition as ht, ProxyHandler as i, spriteStyle as in, ThreadAuthor as it, BatchResult as j, isLinkType as jn, toFilterArray as jt, ProxyClientOptions as k, isDataType as kn, referencedPaths as kt, bytesToBase64 as l, RawFieldSchema as ln, eventLogFilters as lt, FieldReadResult as m, normalizeField as mn, EntityRef as mt, ProxyBody as n, isNativeStatus as nn, SummaryType as nt, ProxyMethod as o, DISPLAY_NAME_FIELDS as on, UploadFile as ot, CreatedField as p, fieldSchemaOverride as pn, ConditionValue as pt, SearchOptions as q, usableStatuses as qt, ProxyError as r, nativeStatus as rn, TextSearchRow as rt, ProxyResult as s, FIELD_SCHEMA_OVERRIDES as sn, UploadResult as st, PROXY_METHODS as t, StockIconSource as tn, SummaryGrouping as tt, createProxyHandler as u, RawFieldsResponse as un, hierarchyEntity as ut, SCHEMA_PROXY_METHODS as v, undeclaredField as vn, LogicalOperator as vt, createSchemaProxyHandler as w, Operator as wn, emptyFilter as wt, SchemaProperties as x, NEGATING_OPERATORS as xn, WireCondition as xt, SchemaApiError as y, DATA_TYPES as yn, Scalar as yt, HierarchyNode as z, foregroundFor as zt };
|