@graphite-sports/sdk 0.4.0 → 0.5.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 (2) hide show
  1. package/index.d.ts +187 -46
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { ColumnDef } from '@tanstack/react-table';
3
3
  import { ColumnHelper } from '@tanstack/table-core';
4
4
  import { ColumnVisibilityState } from '@tanstack/react-table';
5
5
  import { ComponentProps } from 'react';
6
+ import { ComponentType } from 'react';
6
7
  import { CSSProperties } from 'react';
7
8
  import type { DataTag } from '@tanstack/react-query';
8
9
  import { FC } from 'react';
@@ -13,12 +14,14 @@ import { KeyboardEventHandler } from 'react';
13
14
  import { OnChangeFn } from '@tanstack/react-table';
14
15
  import { default as React_2 } from 'react';
15
16
  import * as React_3 from 'react';
17
+ import type { ReactElement } from 'react';
16
18
  import { ReactNode } from 'react';
17
19
  import type { Ref } from 'react';
18
20
  import { RefObject } from 'react';
19
21
  import { RowData } from '@tanstack/react-table';
20
22
  import { RowModel } from '@tanstack/table-core';
21
23
  import { SortingState } from '@tanstack/react-table';
24
+ import { SVGProps } from 'react';
22
25
  import { Tab } from '@headlessui/react';
23
26
  import { TabGroup } from '@headlessui/react';
24
27
  import { Table as Table_2 } from '@tanstack/table-core';
@@ -414,15 +417,6 @@ declare interface components {
414
417
  classId: components["schemas"]["ClassId"];
415
418
  eventId: components["schemas"]["EventId"];
416
419
  };
417
- AddClassesMutation: {
418
- classDtos: components["schemas"]["ClassDTO"][];
419
- eventId: components["schemas"]["EventId"];
420
- /**
421
- * @description The classes get ids derived from it, see [ClassId::nth_of_seed]. Random, picked by the endpoint; reusing a seed
422
- * reproduces the same ids.
423
- */
424
- idSeed: components["schemas"]["Seed"];
425
- };
426
420
  /** @description <C extends {}, P extends Primitive, S extends Sorted|Unsorted>(Table<C, S>, P) -> (Table<C & {<self.key>: P}, S>) */
427
421
  AddColumnsNode: {
428
422
  columns: string[];
@@ -532,10 +526,23 @@ declare interface components {
532
526
  * Later dependencies expect earlier ones to exist.
533
527
  */
534
528
  dependencies: components["schemas"]["Archive"][];
535
- /** Format: uuid */
529
+ /**
530
+ * Format: uint32
531
+ * @description Always [ENGINE_VERSION]: deserializing migrates older archives.
532
+ */
533
+ engineVersion: number;
534
+ /**
535
+ * Format: uuid
536
+ * @description The template the entry belongs to: installing it links the entity to it and reuses the entity of the event
537
+ * installed from it before, see [template_origin](crate::graphite_engine::template_origin). Without one, the entity
538
+ * is installed as a plain editable entity. Ignored for [ArchiveData::Group].
539
+ */
540
+ templateOrigin?: string | null;
541
+ /**
542
+ * Format: uuid
543
+ * @description Identifies the entry within the archive, see [Wiring]. Importing derives the ids of the entities from it.
544
+ */
536
545
  uuid: string;
537
- /** @description The version of the archive system at time of creation of this archive. */
538
- writtenWithVersion: components["schemas"]["SemVer"];
539
546
  };
540
547
  ArchiveData: {
541
548
  /** @constant */
@@ -711,8 +718,7 @@ declare interface components {
711
718
  ClassGender: "female-only" | "male-only" | "all-genders";
712
719
  /**
713
720
  * Format: uuid
714
- * @description Identifies a class. Random ([Self::new_random]) from the endpoint, [Self::nth_of_seed] for `AddClassesMutation`,
715
- * or derived by `ImportArchiveMutation`.
721
+ * @description Identifies a class. Random ([Self::new_random]) from the endpoint, or derived by `ImportArchiveMutation`.
716
722
  * Deserializing one only yields a reference to an existing class; it does not check that it exists.
717
723
  */
718
724
  ClassId: ClassId;
@@ -1240,11 +1246,6 @@ declare interface components {
1240
1246
  */
1241
1247
  nodeUuidSeed: components["schemas"]["Seed"];
1242
1248
  };
1243
- DuplicateGameFormatMutation: {
1244
- /** @description The id of the new copy, see [GameFormatId::new_random]. It must not exist yet. */
1245
- copyId: components["schemas"]["GameFormatId"];
1246
- gameFormatId: components["schemas"]["GameFormatId"];
1247
- };
1248
1249
  /** @description A single encoding definition applied to a single schema property. */
1249
1250
  Encoding: {
1250
1251
  /**
@@ -1607,6 +1608,8 @@ declare interface components {
1607
1608
  /** Format: date-time */
1608
1609
  updatedAt?: string | null;
1609
1610
  };
1611
+ /** @description A value of the local store or the extension store, at most 64 KiB. */
1612
+ ExtensionValue: string;
1610
1613
  /** @description Allows referencing an external resource for extended documentation. */
1611
1614
  ExternalDocumentation: {
1612
1615
  /**
@@ -2571,13 +2574,6 @@ declare interface components {
2571
2574
  /** @enum {string} */
2572
2575
  HeaderStyle: "simple";
2573
2576
  ImportArchiveError: {
2574
- /** @constant */
2575
- type: "incompatible-version";
2576
- data: {
2577
- got: components["schemas"]["SemVer"];
2578
- required: string;
2579
- };
2580
- } | {
2581
2577
  /** @constant */
2582
2578
  type: "invalid-archive";
2583
2579
  data: components["schemas"]["InvalidArchiveError"];
@@ -2596,12 +2592,6 @@ declare interface components {
2596
2592
  ImportArchiveMutation: {
2597
2593
  archive: components["schemas"]["Archive"];
2598
2594
  eventId: components["schemas"]["EventId"];
2599
- /**
2600
- * @description Links the installed entities to their archive entries and reuses entries installed before, see
2601
- * [template_origin](crate::graphite_engine::template_origin). False for log entries written before linking existed.
2602
- * @default false
2603
- */
2604
- linkTemplate: boolean;
2605
2595
  /**
2606
2596
  * @description When `Some`, regenerates format node ids from this seed (deterministic log replay).
2607
2597
  * When `None`, preserves archive node ids — for one-shot imports such as format tests.
@@ -2791,10 +2781,6 @@ declare interface components {
2791
2781
  /** @constant */
2792
2782
  type: "rename-game-format";
2793
2783
  data: components["schemas"]["RenameGameFormatMutation"];
2794
- } | {
2795
- /** @constant */
2796
- type: "duplicate-game-format";
2797
- data: components["schemas"]["DuplicateGameFormatMutation"];
2798
2784
  } | {
2799
2785
  /** @constant */
2800
2786
  type: "delete-game-format";
@@ -2807,10 +2793,6 @@ declare interface components {
2807
2793
  /** @constant */
2808
2794
  type: "add-class";
2809
2795
  data: components["schemas"]["AddClassMutation"];
2810
- } | {
2811
- /** @constant */
2812
- type: "add-classes";
2813
- data: components["schemas"]["AddClassesMutation"];
2814
2796
  } | {
2815
2797
  /** @constant */
2816
2798
  type: "rename-class";
@@ -2819,6 +2801,10 @@ declare interface components {
2819
2801
  /** @constant */
2820
2802
  type: "update-class";
2821
2803
  data: components["schemas"]["UpdateClassMutation"];
2804
+ } | {
2805
+ /** @constant */
2806
+ type: "update-class-state";
2807
+ data: components["schemas"]["UpdateClassStateMutation"];
2822
2808
  } | {
2823
2809
  /** @constant */
2824
2810
  type: "delete-class";
@@ -2991,7 +2977,7 @@ declare interface components {
2991
2977
  LogId: LogId;
2992
2978
  LogsQuery: {
2993
2979
  after: components["schemas"]["LogId"];
2994
- /** Format: int64 */
2980
+ /** Format: uint32 */
2995
2981
  limit: number;
2996
2982
  };
2997
2983
  /**
@@ -4582,10 +4568,6 @@ declare interface components {
4582
4568
  hash: number[];
4583
4569
  id: components["schemas"]["LogId"];
4584
4570
  };
4585
- ReplicationProgressPath: {
4586
- /** Format: uuid */
4587
- taskId: string;
4588
- };
4589
4571
  ReplicationTargetMultipart: {
4590
4572
  /** Format: binary */
4591
4573
  file: Blob;
@@ -5325,6 +5307,10 @@ declare interface components {
5325
5307
  /** @constant */
5326
5308
  type: "detached";
5327
5309
  };
5310
+ TaskPathVariables: {
5311
+ /** Format: uuid */
5312
+ taskId: string;
5313
+ };
5328
5314
  TaskProgressDTO: {
5329
5315
  /** @constant */
5330
5316
  type: "in-progress";
@@ -5355,6 +5341,11 @@ declare interface components {
5355
5341
  /** @constant */
5356
5342
  type: "failed";
5357
5343
  data: {
5344
+ /**
5345
+ * Format: uint
5346
+ * @description The index of the log entry that failed, for tasks that apply log entries.
5347
+ */
5348
+ entry?: number | null;
5358
5349
  error: string;
5359
5350
  };
5360
5351
  };
@@ -5659,6 +5650,9 @@ declare interface components {
5659
5650
  TypeParameters_for_Type_and_ParamRef: {
5660
5651
  [key: string]: components["schemas"]["TypeParameter_for_Type_and_ParamRef"];
5661
5652
  };
5653
+ UninstalledExtensionPath: {
5654
+ extensionIdent: components["schemas"]["ExtensionIdentifier"];
5655
+ };
5662
5656
  /** @enum {string} */
5663
5657
  UniqueBibStrategy: "increment" | "lowest-free";
5664
5658
  /** @description Makes a linked entity editable again. */
@@ -5673,6 +5667,11 @@ declare interface components {
5673
5667
  classDto: components["schemas"]["ClassDTO"];
5674
5668
  id: components["schemas"]["ClassId"];
5675
5669
  };
5670
+ /** @description Changes only the state of a class, which is event data and so also changes on classes linked to a template. */
5671
+ UpdateClassStateMutation: {
5672
+ classId: components["schemas"]["ClassId"];
5673
+ state: components["schemas"]["TableState"];
5674
+ };
5676
5675
  UpdateCompetitorMutation: {
5677
5676
  competitorDto: components["schemas"]["CompetitorDTO"];
5678
5677
  competitorId: components["schemas"]["CompetitorId"];
@@ -5769,6 +5768,13 @@ declare interface components {
5769
5768
  ValidationErrorKind_for_Type: ValidationErrorKind<Type>;
5770
5769
  /** @description A validation error with its location and kind. */
5771
5770
  ValidationError_for_Type: ValidationError<Type>;
5771
+ ValueBody: {
5772
+ value: components["schemas"]["ExtensionValue"];
5773
+ };
5774
+ ValuePath: {
5775
+ extensionIdent: components["schemas"]["ExtensionIdentifier"];
5776
+ key: string;
5777
+ };
5772
5778
  /**
5773
5779
  * Important
5774
5780
  * @description Changes in here are breaking changes for logs
@@ -5913,6 +5919,8 @@ export declare interface DialogButton<T> {
5913
5919
  theme?: 'primary' | 'default' | 'danger';
5914
5920
  }
5915
5921
 
5922
+ export declare type DraggableChildProps = React_2.HTMLAttributes<HTMLElement> & React_2.RefAttributes<HTMLElement>;
5923
+
5916
5924
  /** Spelled out because the inferred `queryOptions` type references TanStack's unexported `dataTagSymbol`, which breaks the SDK's declaration rollup. */
5917
5925
  export declare type EngineQueryOptions<T> = UnusedSkipTokenOptions<T, Error, T, readonly unknown[]> & {
5918
5926
  queryKey: DataTag<readonly unknown[], T, Error>;
@@ -5964,8 +5972,26 @@ export declare function extensionContribution<K extends keyof ExtensionContribut
5964
5972
  export declare type ExtensionContributions = {
5965
5973
  'game-format-page-bottom': GameFormatPageContribution;
5966
5974
  'game-page': GamePageContribution;
5975
+ 'table-drop': TableDropContribution;
5967
5976
  };
5968
5977
 
5978
+ /**
5979
+ * Makes `children` draggable with `payload`. Dropping it onto a table hands `payload` to the `table-drop`
5980
+ * contributions of the calling extension, and to no other extension's.
5981
+ */
5982
+ export declare function ExtensionDraggable({ payload, children }: {
5983
+ payload: string;
5984
+ children: ReactElement<DraggableChildProps>;
5985
+ }): JSX.Element;
5986
+
5987
+ /** What the host lends to extension callbacks that run outside of the extension's components. */
5988
+ export declare interface ExtensionHost {
5989
+ /** Same as {@link useExtensionBackend}. */
5990
+ backend: (path: string, init?: RequestInit) => Promise<Response>;
5991
+ /** Modals whose content can use the extension's hooks, like {@link useExtensionBackend}. */
5992
+ modal: ModalControls;
5993
+ }
5994
+
5969
5995
  export declare type ExtensionInjectPlaceKey = keyof ExtensionContributions;
5970
5996
 
5971
5997
  /**
@@ -6150,6 +6176,15 @@ export declare const getCompetitorsQO: (workspaceId: CommonWorkspaceId, eventId:
6150
6176
 
6151
6177
  export declare const getGameTableResolvedByGameQO: (workspaceId: CommonWorkspaceId, eventId: EventId, gameID: GameId, tableKind: "EntryList" | "ResultList") => EngineQueryOptions<ResolvedTableDTO>;
6152
6178
 
6179
+ /**
6180
+ * The table as nodes see it, with the rows they don't see in `hiddenRows`.
6181
+ */
6182
+ export declare const getGameTableResolvedQueryOptions: (workspaceId: CommonWorkspaceId, eventId: EventId, tableId: TableId) => EngineQueryOptions<ResolvedTableDTO>;
6183
+
6184
+ export declare const getGameTablesByEventQueryOptions: (workspaceId: CommonWorkspaceId, eventId: EventId) => EngineQueryOptions<Map<TableId, TableDAO>>;
6185
+
6186
+ export declare const getStandaloneTablesByEventQueryOptions: (workspaceId: CommonWorkspaceId, eventId: EventId) => EngineQueryOptions<Map<TableId, TableDAO>>;
6187
+
6153
6188
  export declare const getTableByIdQueryOptions: (workspaceId: CommonWorkspaceId, eventId: EventId, tableId: TableId) => EngineQueryOptions<TableWithType>;
6154
6189
 
6155
6190
  /**
@@ -6215,8 +6250,17 @@ export declare type Locales = 'de' | 'en';
6215
6250
  */
6216
6251
  export declare type LocalParamID = number;
6217
6252
 
6253
+ export declare type LogEntry = components['schemas']['LogEntry'];
6254
+
6218
6255
  declare type LogId = Brand<number, 'logId'>;
6219
6256
 
6257
+ /** One step of a log batch: its entries stay together and in order. */
6258
+ export declare interface LogOperation {
6259
+ /** Names the operation when one of its entries fails. */
6260
+ name: string;
6261
+ entries: LogEntry[];
6262
+ }
6263
+
6220
6264
  export declare type MergePathParams<A, B> = {
6221
6265
  [K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never;
6222
6266
  };
@@ -6326,6 +6370,21 @@ declare interface NoSupertypeLayer<T> {
6326
6370
 
6327
6371
  declare type NoSupertypeLayerReason = "UnknownTypeParam" | "NodeSignatureInputsVarg" | "NodeSignatureInputs" | "NodeSignatureOutputs" | "NodeSignatureTags" | "NodeSignatureRequiredTags" | "PortTypesVarg" | "PortTypesArity" | "PortTypesPort" | "Index" | "ConstructorArity" | "ConstructorParam";
6328
6372
 
6373
+ /**
6374
+ * The handle sticking out of the west edge of a panel, vertically centered. It is also the only thing left of the
6375
+ * panel once it is hidden.
6376
+ */
6377
+ export declare function NotchButton({ direction, label, onClick, className, children }: NotchButtonProps): JSX.Element;
6378
+
6379
+ export declare interface NotchButtonProps {
6380
+ /** Where the chevron points: out of the panel to hide it, back into it to bring it in. */
6381
+ direction: 'left' | 'right';
6382
+ label: string;
6383
+ onClick: () => void;
6384
+ className?: string;
6385
+ children?: ReactNode;
6386
+ }
6387
+
6329
6388
  export declare function Note({ children, className }: NoteProps): JSX.Element;
6330
6389
 
6331
6390
  export declare interface NoteProps {
@@ -6628,6 +6687,65 @@ export declare type Shortcut = readonly string[];
6628
6687
  */
6629
6688
  export declare function showDialog<T>(modal: ModalControls, buttons: DialogButton<T>[], content: ReactNode): Promise<T | null>;
6630
6689
 
6690
+ /**
6691
+ * A panel as a column of its own, next to the content. Keeping it out of the content gives toolbars the whole
6692
+ * width, and collapsing it hands the space back. Hidden on mobile, see {@link SidePanelDrawer}.
6693
+ */
6694
+ export declare function SidePanelDock({ storageKey, icon: Icon, badge, expandLabel, children }: SidePanelDockProps): JSX.Element;
6695
+
6696
+ export declare interface SidePanelDockProps {
6697
+ /** Remembers whether the panel is open. */
6698
+ storageKey: string;
6699
+ icon: SidePanelIcon;
6700
+ /** Shown on the notch while the panel is hidden. */
6701
+ badge?: ReactNode;
6702
+ expandLabel: string;
6703
+ children: (onClose: () => void) => ReactNode;
6704
+ }
6705
+
6706
+ /** On mobile a panel has no room of its own, so it waits behind a button and slides in over the content. */
6707
+ export declare function SidePanelDrawer({ icon: Icon, label, title, badge, closeLabel, buttonClassName, children, }: SidePanelDrawerProps): JSX.Element;
6708
+
6709
+ export declare interface SidePanelDrawerProps {
6710
+ icon: SidePanelIcon;
6711
+ label: string;
6712
+ title: string;
6713
+ badge?: ReactNode;
6714
+ closeLabel: string;
6715
+ /** Where the button opening the drawer sits. */
6716
+ buttonClassName?: string;
6717
+ children: (onClose: () => void) => ReactNode;
6718
+ }
6719
+
6720
+ export declare function SidePanelFooterButton({ onClick, disabled, children }: SidePanelFooterButtonProps): JSX.Element;
6721
+
6722
+ export declare interface SidePanelFooterButtonProps {
6723
+ onClick: () => void;
6724
+ disabled: boolean;
6725
+ children: string;
6726
+ }
6727
+
6728
+ /** A panel with a title, a scrolling body and an optional footer. The notch on its west edge closes it. */
6729
+ export declare function SidePanelFrame({ variant, icon: Icon, title, meta, closeLabel, onClose, footer, className, children, }: SidePanelFrameProps): JSX.Element;
6730
+
6731
+ export declare interface SidePanelFrameProps {
6732
+ /** Docked next to the content, or floating above it as the mobile drawer. */
6733
+ variant: SidePanelVariant;
6734
+ icon: SidePanelIcon;
6735
+ title: string;
6736
+ /** Shown at the right of the title, like how many items are selected. */
6737
+ meta?: ReactNode;
6738
+ closeLabel: string;
6739
+ onClose: () => void;
6740
+ footer?: ReactNode;
6741
+ className?: string;
6742
+ children: ReactNode;
6743
+ }
6744
+
6745
+ export declare type SidePanelIcon = ComponentType<SVGProps<SVGSVGElement>>;
6746
+
6747
+ export declare type SidePanelVariant = 'dock' | 'drawer';
6748
+
6631
6749
  declare type Sorted = Brand<'sorted', 'sorted'>;
6632
6750
 
6633
6751
  /**
@@ -6658,6 +6776,23 @@ declare type Table<SortingState, M = NoMetadata> = { rows: Rows<SortingState> }
6658
6776
 
6659
6777
  export declare type TableDAO = components['schemas']['TableDAO'];
6660
6778
 
6779
+ /**
6780
+ * Accepts payloads dragged with {@link ExtensionDraggable} of the same extension onto tables: standalone tables,
6781
+ * and the entry and result tables of games. The first contribution whose `canDrop` accepts a payload takes it;
6782
+ * payloads that none accepts can't be dropped.
6783
+ */
6784
+ export declare interface TableDropContribution {
6785
+ canDrop(payload: string, target: TableDropTarget): boolean;
6786
+ onDrop(payload: string, target: TableDropTarget, host: ExtensionHost): void | Promise<void>;
6787
+ /** Shown on the highlighted drop area. */
6788
+ label?: Record<Locales, string>;
6789
+ }
6790
+
6791
+ /** `table.variant` tells standalone and game tables apart, `table.tableKind` entry and result tables. */
6792
+ export declare type TableDropTarget = EventPath & {
6793
+ table: TableDAO;
6794
+ };
6795
+
6661
6796
  export declare type TableId = Brand<string, 'tableId'>;
6662
6797
 
6663
6798
  export declare interface TableProps<TData extends RowData> {
@@ -6784,7 +6919,7 @@ declare type Unsorted_2 = null;
6784
6919
  export declare function useEngineLocale(): Locales;
6785
6920
 
6786
6921
  /** Returns a `fetch` for `path` (relative, e.g. `"items"`) on the calling extension's own backend in the current event. */
6787
- export declare function useExtensionBackend(): (path: string, init?: RequestInit) => Promise<Response>;
6922
+ export declare function useExtensionBackend(): ExtensionHost['backend'];
6788
6923
 
6789
6924
  /** The identifier the calling extension is installed under, e.g. the key of its `extensionData`. */
6790
6925
  export declare function useExtensionIdentifier(): string;
@@ -6808,6 +6943,12 @@ export declare function usePersistedState<S>(storageKey: string, initialState: S
6808
6943
  /** Hook to use the router context. Must be called within a <Router> provider. */
6809
6944
  export declare function useRouter(): RouterContextType;
6810
6945
 
6946
+ /**
6947
+ * Returns a function that applies the entries of all operations in one all-or-nothing `POST /log` with a progress modal
6948
+ * and reports a failure, like `runLogBatch`, with the modals and translations of the calling component.
6949
+ */
6950
+ export declare function useRunLogBatch(): (workspaceId: CommonWorkspaceId, operations: LogOperation[], label: ReactNode) => Promise<boolean | null>;
6951
+
6811
6952
  /** The `:` params that are uuids, by name. All other `:` params are numbers. */
6812
6953
  declare type UuidPathParams = {
6813
6954
  classId: ClassId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphite-sports/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "repository": "github:Graphite-sports/starter-extension",
6
6
  "homepage": "https://github.com/Graphite-sports/starter-extension",