From 31dff8fdadb11b78e6b5ecb486d6ec62b8334adc Mon Sep 17 00:00:00 2001 From: Chad Burt Date: Tue, 23 Apr 2024 11:59:56 -0700 Subject: [PATCH] Adding archived_data_sources table for tracking uploaded source replacements (#735) --- packages/api/generated-schema-clean.gql | 140 ++++++++++++++++++ packages/api/generated-schema.gql | 140 ++++++++++++++++++ packages/api/migrations/committed/000329.sql | 73 +++++++++ packages/api/schema.sql | 109 +++++++++++++- .../api/tasks/cleanupDeletedOverlayRecords.ts | 2 + packages/client/src/generated/graphql.ts | 115 ++++++++++++++ packages/client/src/generated/queries.ts | 115 ++++++++++++++ 7 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 packages/api/migrations/committed/000329.sql diff --git a/packages/api/generated-schema-clean.gql b/packages/api/generated-schema-clean.gql index 601e514b..09832ee2 100644 --- a/packages/api/generated-schema-clean.gql +++ b/packages/api/generated-schema-clean.gql @@ -244,6 +244,91 @@ enum ArcgisSourceType { ARCGIS_VECTOR } +""" +Admins can upload new version of data sources, and these are tracked from this +table. This is used to track changes to data sources over time with a version +number and optional changelog. +""" +type ArchivedDataSource implements Node { + """ + Optional changelog so that admins can explain what changed in the new version. + """ + changelog: String + dataLayerId: Int! + + """ + Reads a single `DataSource` that is related to this `ArchivedDataSource`. + """ + dataSource: DataSource + dataSourceId: Int! + + """ + Mapbox GL style from the associated data layer at the time of upload of the + new version. This is tracked in case the data source is significantly changed + such that rolling back to a previous version also requires style changes + """ + mapboxGlStyle: JSON! + + """ + A globally unique identifier. Can be used in various places throughout the system to identify this single value. + """ + nodeId: ID! + + """Array of sprite ids used in the archived mapbox_gl_style.""" + spriteIds: [Int] + + """ + Version number of the data source. Incremented each time a new version is uploaded. + """ + version: Int! +} + +""" +A condition to be used against `ArchivedDataSource` object types. All fields are +tested for equality and combined with a logical ‘and.’ +""" +input ArchivedDataSourceCondition { + """Checks for equality with the object’s `dataSourceId` field.""" + dataSourceId: Int +} + +"""A connection to a list of `ArchivedDataSource` values.""" +type ArchivedDataSourcesConnection { + """ + A list of edges which contains the `ArchivedDataSource` and cursor to aid in pagination. + """ + edges: [ArchivedDataSourcesEdge!]! + + """A list of `ArchivedDataSource` objects.""" + nodes: [ArchivedDataSource!]! + + """Information to aid in pagination.""" + pageInfo: PageInfo! + + """ + The count of *all* `ArchivedDataSource` you could get from the connection. + """ + totalCount: Int! +} + +"""A `ArchivedDataSource` edge in the connection.""" +type ArchivedDataSourcesEdge { + """A cursor for use in pagination.""" + cursor: Cursor + + """The `ArchivedDataSource` at the end of the edge.""" + node: ArchivedDataSource! +} + +"""Methods to use when ordering `ArchivedDataSource`.""" +enum ArchivedDataSourcesOrderBy { + DATA_SOURCE_ID_ASC + DATA_SOURCE_ID_DESC + NATURAL + PRIMARY_KEY_ASC + PRIMARY_KEY_DESC +} + """All input for the `archiveResponses` mutation.""" input ArchiveResponsesInput { """ @@ -2412,6 +2497,23 @@ When documentation is lacking for any of these properties, consult the [MapBox G type DataSource implements Node { arcgisFetchStrategy: ArcgisFeatureLayerFetchStrategy! + """Reads and enables pagination through a set of `ArchivedDataSource`.""" + archivedDataSources( + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: ArchivedDataSourceCondition + + """Only read the first `n` values of the set.""" + first: Int + + """Skip the first `n` values.""" + offset: Int + + """The method to use when ordering `ArchivedDataSource`.""" + orderBy: [ArchivedDataSourcesOrderBy!] + ): [ArchivedDataSource!]! + """ Contains an attribution to be displayed when the map is shown to a user. """ @@ -11201,6 +11303,44 @@ type Query implements Node { offset: Int period: ActivityStatsPeriod ): [Project!] + archivedDataSource(dataLayerId: Int!, dataSourceId: Int!, version: Int!): ArchivedDataSource + + """Reads a single `ArchivedDataSource` using its globally unique `ID`.""" + archivedDataSourceByNodeId( + """ + The globally unique `ID` to be used in selecting a single `ArchivedDataSource`. + """ + nodeId: ID! + ): ArchivedDataSource + + """Reads and enables pagination through a set of `ArchivedDataSource`.""" + archivedDataSourcesConnection( + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: ArchivedDataSourceCondition + + """Only read the first `n` values of the set.""" + first: Int + + """Only read the last `n` values of the set.""" + last: Int + + """ + Skip the first `n` values from our `after` cursor, an alternative to cursor + based pagination. May not be used with `last`. + """ + offset: Int + + """The method to use when ordering `ArchivedDataSource`.""" + orderBy: [ArchivedDataSourcesOrderBy!] = [PRIMARY_KEY_ASC] + ): ArchivedDataSourcesConnection basemap(id: Int!): Basemap """Reads a single `Basemap` using its globally unique `ID`.""" diff --git a/packages/api/generated-schema.gql b/packages/api/generated-schema.gql index 601e514b..09832ee2 100644 --- a/packages/api/generated-schema.gql +++ b/packages/api/generated-schema.gql @@ -244,6 +244,91 @@ enum ArcgisSourceType { ARCGIS_VECTOR } +""" +Admins can upload new version of data sources, and these are tracked from this +table. This is used to track changes to data sources over time with a version +number and optional changelog. +""" +type ArchivedDataSource implements Node { + """ + Optional changelog so that admins can explain what changed in the new version. + """ + changelog: String + dataLayerId: Int! + + """ + Reads a single `DataSource` that is related to this `ArchivedDataSource`. + """ + dataSource: DataSource + dataSourceId: Int! + + """ + Mapbox GL style from the associated data layer at the time of upload of the + new version. This is tracked in case the data source is significantly changed + such that rolling back to a previous version also requires style changes + """ + mapboxGlStyle: JSON! + + """ + A globally unique identifier. Can be used in various places throughout the system to identify this single value. + """ + nodeId: ID! + + """Array of sprite ids used in the archived mapbox_gl_style.""" + spriteIds: [Int] + + """ + Version number of the data source. Incremented each time a new version is uploaded. + """ + version: Int! +} + +""" +A condition to be used against `ArchivedDataSource` object types. All fields are +tested for equality and combined with a logical ‘and.’ +""" +input ArchivedDataSourceCondition { + """Checks for equality with the object’s `dataSourceId` field.""" + dataSourceId: Int +} + +"""A connection to a list of `ArchivedDataSource` values.""" +type ArchivedDataSourcesConnection { + """ + A list of edges which contains the `ArchivedDataSource` and cursor to aid in pagination. + """ + edges: [ArchivedDataSourcesEdge!]! + + """A list of `ArchivedDataSource` objects.""" + nodes: [ArchivedDataSource!]! + + """Information to aid in pagination.""" + pageInfo: PageInfo! + + """ + The count of *all* `ArchivedDataSource` you could get from the connection. + """ + totalCount: Int! +} + +"""A `ArchivedDataSource` edge in the connection.""" +type ArchivedDataSourcesEdge { + """A cursor for use in pagination.""" + cursor: Cursor + + """The `ArchivedDataSource` at the end of the edge.""" + node: ArchivedDataSource! +} + +"""Methods to use when ordering `ArchivedDataSource`.""" +enum ArchivedDataSourcesOrderBy { + DATA_SOURCE_ID_ASC + DATA_SOURCE_ID_DESC + NATURAL + PRIMARY_KEY_ASC + PRIMARY_KEY_DESC +} + """All input for the `archiveResponses` mutation.""" input ArchiveResponsesInput { """ @@ -2412,6 +2497,23 @@ When documentation is lacking for any of these properties, consult the [MapBox G type DataSource implements Node { arcgisFetchStrategy: ArcgisFeatureLayerFetchStrategy! + """Reads and enables pagination through a set of `ArchivedDataSource`.""" + archivedDataSources( + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: ArchivedDataSourceCondition + + """Only read the first `n` values of the set.""" + first: Int + + """Skip the first `n` values.""" + offset: Int + + """The method to use when ordering `ArchivedDataSource`.""" + orderBy: [ArchivedDataSourcesOrderBy!] + ): [ArchivedDataSource!]! + """ Contains an attribution to be displayed when the map is shown to a user. """ @@ -11201,6 +11303,44 @@ type Query implements Node { offset: Int period: ActivityStatsPeriod ): [Project!] + archivedDataSource(dataLayerId: Int!, dataSourceId: Int!, version: Int!): ArchivedDataSource + + """Reads a single `ArchivedDataSource` using its globally unique `ID`.""" + archivedDataSourceByNodeId( + """ + The globally unique `ID` to be used in selecting a single `ArchivedDataSource`. + """ + nodeId: ID! + ): ArchivedDataSource + + """Reads and enables pagination through a set of `ArchivedDataSource`.""" + archivedDataSourcesConnection( + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: ArchivedDataSourceCondition + + """Only read the first `n` values of the set.""" + first: Int + + """Only read the last `n` values of the set.""" + last: Int + + """ + Skip the first `n` values from our `after` cursor, an alternative to cursor + based pagination. May not be used with `last`. + """ + offset: Int + + """The method to use when ordering `ArchivedDataSource`.""" + orderBy: [ArchivedDataSourcesOrderBy!] = [PRIMARY_KEY_ASC] + ): ArchivedDataSourcesConnection basemap(id: Int!): Basemap """Reads a single `Basemap` using its globally unique `ID`.""" diff --git a/packages/api/migrations/committed/000329.sql b/packages/api/migrations/committed/000329.sql new file mode 100644 index 00000000..add7cf4c --- /dev/null +++ b/packages/api/migrations/committed/000329.sql @@ -0,0 +1,73 @@ +--! Previous: sha1:5a121ffbecd4ef38ef0cfe56433328d5d5c3dd39 +--! Hash: sha1:70af5c278ab4307d6445e6dcce482838d3d4ef96 + +-- Enter migration here +drop table if exists archived_data_sources; + +create table archived_data_sources ( + data_source_id integer not null references data_sources(id) on delete cascade, + data_layer_id integer not null references data_layers(id) on delete cascade, + version integer not null, + mapbox_gl_style jsonb not null, + sprite_ids integer[] generated always as (extract_sprite_ids(mapbox_gl_style::text)) stored, + changelog text, + primary key (data_source_id, data_layer_id, version) +); + +grant select on archived_data_sources to seasketch_user; + +alter table archived_data_sources enable row level security; + +create policy select_archived_data_sources_policy on archived_data_sources for select using (session_is_admin((select project_id from data_sources where id = data_source_id))); + +COMMENT ON CONSTRAINT archived_data_sources_data_source_id_fkey ON public.archived_data_sources IS ' +@simpleCollections only +'; + +comment on table archived_data_sources is 'Admins can upload new version of data sources, and these are tracked from this table. This is used to track changes to data sources over time with a version number and optional changelog.'; + +comment on column archived_data_sources.version is 'Version number of the data source. Incremented each time a new version is uploaded.'; + +comment on column archived_data_sources.mapbox_gl_style is 'Mapbox GL style from the associated data layer at the time of upload of the new version. This is tracked in case the data source is significantly changed such that rolling back to a previous version also requires style changes'; + +comment on column archived_data_sources.sprite_ids is 'Array of sprite ids used in the archived mapbox_gl_style.'; + +comment on column archived_data_sources.changelog is 'Optional changelog so that admins can explain what changed in the new version.'; + +CREATE OR REPLACE FUNCTION public.projects_data_hosting_quota_used(p public.projects) RETURNS bigint + LANGUAGE plpgsql STABLE SECURITY DEFINER + AS $$ + declare + sum_bytes bigint; + quota bigint; + begin + if session_is_admin(p.id) != true then + raise 'Permission denied'; + end if; + select + sum(size) + into + sum_bytes + from + data_upload_outputs + where + data_source_id = any ( + select id from data_sources where id = any ( + select data_source_id from data_layers where id = any ( + select data_layer_id from table_of_contents_items where project_id = p.id and data_layer_id is not null and is_draft = true + ) union + select data_source_id from archived_data_sources where data_source_id = any ( + select id from data_sources where project_id = p.id + ) + ) + ); + select projects_data_hosting_quota(p) into quota; + if sum_bytes < quota then + return sum_bytes; + end if; + if sum_bytes is null then + return 0; + end if; + return quota; + end; + $$; diff --git a/packages/api/schema.sql b/packages/api/schema.sql index de903c27..089c69c3 100644 --- a/packages/api/schema.sql +++ b/packages/api/schema.sql @@ -11290,6 +11290,9 @@ CREATE FUNCTION public.projects_data_hosting_quota_used(p public.projects) RETUR select id from data_sources where id = any ( select data_source_id from data_layers where id = any ( select data_layer_id from table_of_contents_items where project_id = p.id and data_layer_id is not null and is_draft = true + ) union + select data_source_id from archived_data_sources where data_source_id = any ( + select id from data_sources where project_id = p.id ) ) ); @@ -15197,7 +15200,7 @@ CREATE FUNCTION public.table_of_contents_items_project_update() RETURNS trigger CREATE FUNCTION public.table_of_contents_items_total_requests(item public.table_of_contents_items, period public.activity_stats_period) RETURNS integer LANGUAGE sql STABLE SECURITY DEFINER AS $$ - select sum(count) from data_source_requests where interval = ( + select sum(count)::integer from data_source_requests where interval = ( case period when '24hrs' then '15 minutes'::interval when '7-days' then '1 hour'::interval @@ -16580,6 +16583,55 @@ ALTER TABLE public.access_control_lists ALTER COLUMN id ADD GENERATED BY DEFAULT ); +-- +-- Name: archived_data_sources; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.archived_data_sources ( + data_source_id integer NOT NULL, + data_layer_id integer NOT NULL, + version integer NOT NULL, + mapbox_gl_style jsonb NOT NULL, + sprite_ids integer[] GENERATED ALWAYS AS (public.extract_sprite_ids((mapbox_gl_style)::text)) STORED, + changelog text +); + + +-- +-- Name: TABLE archived_data_sources; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.archived_data_sources IS 'Admins can upload new version of data sources, and these are tracked from this table. This is used to track changes to data sources over time with a version number and optional changelog.'; + + +-- +-- Name: COLUMN archived_data_sources.version; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.archived_data_sources.version IS 'Version number of the data source. Incremented each time a new version is uploaded.'; + + +-- +-- Name: COLUMN archived_data_sources.mapbox_gl_style; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.archived_data_sources.mapbox_gl_style IS 'Mapbox GL style from the associated data layer at the time of upload of the new version. This is tracked in case the data source is significantly changed such that rolling back to a previous version also requires style changes'; + + +-- +-- Name: COLUMN archived_data_sources.sprite_ids; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.archived_data_sources.sprite_ids IS 'Array of sprite ids used in the archived mapbox_gl_style.'; + + +-- +-- Name: COLUMN archived_data_sources.changelog; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON COLUMN public.archived_data_sources.changelog IS 'Optional changelog so that admins can explain what changed in the new version.'; + + -- -- Name: basemaps_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- @@ -17730,6 +17782,14 @@ ALTER TABLE ONLY public.access_control_lists ADD CONSTRAINT access_control_lists_table_of_contents_item_id_key UNIQUE (table_of_contents_item_id); +-- +-- Name: archived_data_sources archived_data_sources_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.archived_data_sources + ADD CONSTRAINT archived_data_sources_pkey PRIMARY KEY (data_source_id, data_layer_id, version); + + -- -- Name: basemaps basemaps_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -19667,6 +19727,31 @@ ALTER TABLE ONLY public.access_control_lists ADD CONSTRAINT access_control_lists_table_of_contents_item_id_fkey FOREIGN KEY (table_of_contents_item_id) REFERENCES public.table_of_contents_items(id) ON DELETE CASCADE; +-- +-- Name: archived_data_sources archived_data_sources_data_layer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.archived_data_sources + ADD CONSTRAINT archived_data_sources_data_layer_id_fkey FOREIGN KEY (data_layer_id) REFERENCES public.data_layers(id) ON DELETE CASCADE; + + +-- +-- Name: archived_data_sources archived_data_sources_data_source_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.archived_data_sources + ADD CONSTRAINT archived_data_sources_data_source_id_fkey FOREIGN KEY (data_source_id) REFERENCES public.data_sources(id) ON DELETE CASCADE; + + +-- +-- Name: CONSTRAINT archived_data_sources_data_source_id_fkey ON archived_data_sources; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON CONSTRAINT archived_data_sources_data_source_id_fkey ON public.archived_data_sources IS ' +@simpleCollections only +'; + + -- -- Name: basemaps basemaps_interactivity_settings_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -20760,6 +20845,12 @@ CREATE POLICY access_control_lists_update ON public.access_control_lists FOR UPD WHERE (basemaps.id = access_control_lists.basemap_id))))); +-- +-- Name: archived_data_sources; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.archived_data_sources ENABLE ROW LEVEL SECURITY; + -- -- Name: basemaps; Type: ROW SECURITY; Schema: public; Owner: - -- @@ -21262,6 +21353,15 @@ CREATE POLICY projects_shared_basemaps_select ON public.projects_shared_basemaps CREATE POLICY projects_update ON public.projects FOR UPDATE TO seasketch_user USING (public.session_is_admin(id)) WITH CHECK (public.session_is_admin(id)); +-- +-- Name: archived_data_sources select_archived_data_sources_policy; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY select_archived_data_sources_policy ON public.archived_data_sources FOR SELECT USING (public.session_is_admin(( SELECT data_sources.project_id + FROM public.data_sources + WHERE (data_sources.id = archived_data_sources.data_source_id)))); + + -- -- Name: project_participants select_project_participants; Type: POLICY; Schema: public; Owner: - -- @@ -32435,6 +32535,13 @@ REVOKE ALL ON FUNCTION public.st_union(public.geometry, double precision) FROM P GRANT SELECT ON TABLE public.access_control_list_groups TO seasketch_user; +-- +-- Name: TABLE archived_data_sources; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT ON TABLE public.archived_data_sources TO seasketch_user; + + -- -- Name: TABLE community_guidelines; Type: ACL; Schema: public; Owner: - -- diff --git a/packages/api/tasks/cleanupDeletedOverlayRecords.ts b/packages/api/tasks/cleanupDeletedOverlayRecords.ts index 1c0222d2..a6e0e9c1 100644 --- a/packages/api/tasks/cleanupDeletedOverlayRecords.ts +++ b/packages/api/tasks/cleanupDeletedOverlayRecords.ts @@ -57,6 +57,8 @@ export default async function cleanupDeletedOverlayRecords( results = await client.query(` delete from data_sources where not exists ( select id from data_layers where data_source_id = data_sources.id + ) and not exists ( + select data_source_id from archived_data_sources where data_source_id = data_sources.id ); `); if (results.rowCount > 0) { diff --git a/packages/client/src/generated/graphql.ts b/packages/client/src/generated/graphql.ts index 6ae5c8b8..61abaec2 100644 --- a/packages/client/src/generated/graphql.ts +++ b/packages/client/src/generated/graphql.ts @@ -298,6 +298,73 @@ export type ArchiveResponsesPayload = { surveyResponses?: Maybe>; }; +/** + * Admins can upload new version of data sources, and these are tracked from this + * table. This is used to track changes to data sources over time with a version + * number and optional changelog. + */ +export type ArchivedDataSource = Node & { + __typename?: 'ArchivedDataSource'; + /** Optional changelog so that admins can explain what changed in the new version. */ + changelog?: Maybe; + dataLayerId: Scalars['Int']; + /** Reads a single `DataSource` that is related to this `ArchivedDataSource`. */ + dataSource?: Maybe; + dataSourceId: Scalars['Int']; + /** + * Mapbox GL style from the associated data layer at the time of upload of the + * new version. This is tracked in case the data source is significantly changed + * such that rolling back to a previous version also requires style changes + */ + mapboxGlStyle: Scalars['JSON']; + /** A globally unique identifier. Can be used in various places throughout the system to identify this single value. */ + nodeId: Scalars['ID']; + /** Array of sprite ids used in the archived mapbox_gl_style. */ + spriteIds?: Maybe>>; + /** Version number of the data source. Incremented each time a new version is uploaded. */ + version: Scalars['Int']; +}; + +/** + * A condition to be used against `ArchivedDataSource` object types. All fields are + * tested for equality and combined with a logical ‘and.’ + */ +export type ArchivedDataSourceCondition = { + /** Checks for equality with the object’s `dataSourceId` field. */ + dataSourceId?: Maybe; +}; + +/** A connection to a list of `ArchivedDataSource` values. */ +export type ArchivedDataSourcesConnection = { + __typename?: 'ArchivedDataSourcesConnection'; + /** A list of edges which contains the `ArchivedDataSource` and cursor to aid in pagination. */ + edges: Array; + /** A list of `ArchivedDataSource` objects. */ + nodes: Array; + /** Information to aid in pagination. */ + pageInfo: PageInfo; + /** The count of *all* `ArchivedDataSource` you could get from the connection. */ + totalCount: Scalars['Int']; +}; + +/** A `ArchivedDataSource` edge in the connection. */ +export type ArchivedDataSourcesEdge = { + __typename?: 'ArchivedDataSourcesEdge'; + /** A cursor for use in pagination. */ + cursor?: Maybe; + /** The `ArchivedDataSource` at the end of the edge. */ + node: ArchivedDataSource; +}; + +/** Methods to use when ordering `ArchivedDataSource`. */ +export enum ArchivedDataSourcesOrderBy { + DataSourceIdAsc = 'DATA_SOURCE_ID_ASC', + DataSourceIdDesc = 'DATA_SOURCE_ID_DESC', + Natural = 'NATURAL', + PrimaryKeyAsc = 'PRIMARY_KEY_ASC', + PrimaryKeyDesc = 'PRIMARY_KEY_DESC' +} + export type Basemap = Node & { __typename?: 'Basemap'; /** Reads a single `Acl` that is related to this `Basemap`. */ @@ -2144,6 +2211,8 @@ export enum DataLayersOrderBy { export type DataSource = Node & { __typename?: 'DataSource'; arcgisFetchStrategy: ArcgisFeatureLayerFetchStrategy; + /** Reads and enables pagination through a set of `ArchivedDataSource`. */ + archivedDataSources: Array; /** Contains an attribution to be displayed when the map is shown to a user. */ attribution?: Maybe; /** @@ -2303,6 +2372,21 @@ export type DataSource = Node & { }; +/** + * SeaSketch DataSources are analogous to MapBox GL Style sources but are extended + * to include new types to support services such as ArcGIS MapServers and content + * hosted on the SeaSketch CDN. + * + * When documentation is lacking for any of these properties, consult the [MapBox GL Style docs](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson-promoteId) + */ +export type DataSourceArchivedDataSourcesArgs = { + condition?: Maybe; + first?: Maybe; + offset?: Maybe; + orderBy?: Maybe>; +}; + + /** * SeaSketch DataSources are analogous to MapBox GL Style sources but are extended * to include new types to support services such as ArcGIS MapServers and content @@ -10025,6 +10109,11 @@ export type Query = Node & { aclByTableOfContentsItemId?: Maybe; /** Reads and enables pagination through a set of `Project`. */ activeProjects?: Maybe>; + archivedDataSource?: Maybe; + /** Reads a single `ArchivedDataSource` using its globally unique `ID`. */ + archivedDataSourceByNodeId?: Maybe; + /** Reads and enables pagination through a set of `ArchivedDataSource`. */ + archivedDataSourcesConnection?: Maybe; basemap?: Maybe; /** Reads a single `Basemap` using its globally unique `ID`. */ basemapByNodeId?: Maybe; @@ -10302,6 +10391,32 @@ export type QueryActiveProjectsArgs = { }; +/** The root query type which gives access points into the data universe. */ +export type QueryArchivedDataSourceArgs = { + dataLayerId: Scalars['Int']; + dataSourceId: Scalars['Int']; + version: Scalars['Int']; +}; + + +/** The root query type which gives access points into the data universe. */ +export type QueryArchivedDataSourceByNodeIdArgs = { + nodeId: Scalars['ID']; +}; + + +/** The root query type which gives access points into the data universe. */ +export type QueryArchivedDataSourcesConnectionArgs = { + after?: Maybe; + before?: Maybe; + condition?: Maybe; + first?: Maybe; + last?: Maybe; + offset?: Maybe; + orderBy?: Maybe>; +}; + + /** The root query type which gives access points into the data universe. */ export type QueryBasemapArgs = { id: Scalars['Int']; diff --git a/packages/client/src/generated/queries.ts b/packages/client/src/generated/queries.ts index 904e2da6..be92dadc 100644 --- a/packages/client/src/generated/queries.ts +++ b/packages/client/src/generated/queries.ts @@ -296,6 +296,73 @@ export type ArchiveResponsesPayload = { surveyResponses?: Maybe>; }; +/** + * Admins can upload new version of data sources, and these are tracked from this + * table. This is used to track changes to data sources over time with a version + * number and optional changelog. + */ +export type ArchivedDataSource = Node & { + __typename?: 'ArchivedDataSource'; + /** Optional changelog so that admins can explain what changed in the new version. */ + changelog?: Maybe; + dataLayerId: Scalars['Int']; + /** Reads a single `DataSource` that is related to this `ArchivedDataSource`. */ + dataSource?: Maybe; + dataSourceId: Scalars['Int']; + /** + * Mapbox GL style from the associated data layer at the time of upload of the + * new version. This is tracked in case the data source is significantly changed + * such that rolling back to a previous version also requires style changes + */ + mapboxGlStyle: Scalars['JSON']; + /** A globally unique identifier. Can be used in various places throughout the system to identify this single value. */ + nodeId: Scalars['ID']; + /** Array of sprite ids used in the archived mapbox_gl_style. */ + spriteIds?: Maybe>>; + /** Version number of the data source. Incremented each time a new version is uploaded. */ + version: Scalars['Int']; +}; + +/** + * A condition to be used against `ArchivedDataSource` object types. All fields are + * tested for equality and combined with a logical ‘and.’ + */ +export type ArchivedDataSourceCondition = { + /** Checks for equality with the object’s `dataSourceId` field. */ + dataSourceId?: Maybe; +}; + +/** A connection to a list of `ArchivedDataSource` values. */ +export type ArchivedDataSourcesConnection = { + __typename?: 'ArchivedDataSourcesConnection'; + /** A list of edges which contains the `ArchivedDataSource` and cursor to aid in pagination. */ + edges: Array; + /** A list of `ArchivedDataSource` objects. */ + nodes: Array; + /** Information to aid in pagination. */ + pageInfo: PageInfo; + /** The count of *all* `ArchivedDataSource` you could get from the connection. */ + totalCount: Scalars['Int']; +}; + +/** A `ArchivedDataSource` edge in the connection. */ +export type ArchivedDataSourcesEdge = { + __typename?: 'ArchivedDataSourcesEdge'; + /** A cursor for use in pagination. */ + cursor?: Maybe; + /** The `ArchivedDataSource` at the end of the edge. */ + node: ArchivedDataSource; +}; + +/** Methods to use when ordering `ArchivedDataSource`. */ +export enum ArchivedDataSourcesOrderBy { + DataSourceIdAsc = 'DATA_SOURCE_ID_ASC', + DataSourceIdDesc = 'DATA_SOURCE_ID_DESC', + Natural = 'NATURAL', + PrimaryKeyAsc = 'PRIMARY_KEY_ASC', + PrimaryKeyDesc = 'PRIMARY_KEY_DESC' +} + export type Basemap = Node & { __typename?: 'Basemap'; /** Reads a single `Acl` that is related to this `Basemap`. */ @@ -2142,6 +2209,8 @@ export enum DataLayersOrderBy { export type DataSource = Node & { __typename?: 'DataSource'; arcgisFetchStrategy: ArcgisFeatureLayerFetchStrategy; + /** Reads and enables pagination through a set of `ArchivedDataSource`. */ + archivedDataSources: Array; /** Contains an attribution to be displayed when the map is shown to a user. */ attribution?: Maybe; /** @@ -2301,6 +2370,21 @@ export type DataSource = Node & { }; +/** + * SeaSketch DataSources are analogous to MapBox GL Style sources but are extended + * to include new types to support services such as ArcGIS MapServers and content + * hosted on the SeaSketch CDN. + * + * When documentation is lacking for any of these properties, consult the [MapBox GL Style docs](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson-promoteId) + */ +export type DataSourceArchivedDataSourcesArgs = { + condition?: Maybe; + first?: Maybe; + offset?: Maybe; + orderBy?: Maybe>; +}; + + /** * SeaSketch DataSources are analogous to MapBox GL Style sources but are extended * to include new types to support services such as ArcGIS MapServers and content @@ -10023,6 +10107,11 @@ export type Query = Node & { aclByTableOfContentsItemId?: Maybe; /** Reads and enables pagination through a set of `Project`. */ activeProjects?: Maybe>; + archivedDataSource?: Maybe; + /** Reads a single `ArchivedDataSource` using its globally unique `ID`. */ + archivedDataSourceByNodeId?: Maybe; + /** Reads and enables pagination through a set of `ArchivedDataSource`. */ + archivedDataSourcesConnection?: Maybe; basemap?: Maybe; /** Reads a single `Basemap` using its globally unique `ID`. */ basemapByNodeId?: Maybe; @@ -10300,6 +10389,32 @@ export type QueryActiveProjectsArgs = { }; +/** The root query type which gives access points into the data universe. */ +export type QueryArchivedDataSourceArgs = { + dataLayerId: Scalars['Int']; + dataSourceId: Scalars['Int']; + version: Scalars['Int']; +}; + + +/** The root query type which gives access points into the data universe. */ +export type QueryArchivedDataSourceByNodeIdArgs = { + nodeId: Scalars['ID']; +}; + + +/** The root query type which gives access points into the data universe. */ +export type QueryArchivedDataSourcesConnectionArgs = { + after?: Maybe; + before?: Maybe; + condition?: Maybe; + first?: Maybe; + last?: Maybe; + offset?: Maybe; + orderBy?: Maybe>; +}; + + /** The root query type which gives access points into the data universe. */ export type QueryBasemapArgs = { id: Scalars['Int'];