feat(acc): blind change on update delete mutations from lineageUrn to id
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
extend type Project {
|
||||
accSyncItems(cursor: String, limit: Int): AccSyncItemCollection!
|
||||
accSyncItem(lineageUrn: String!): AccSyncItem!
|
||||
accSyncItem(id: String!): AccSyncItem!
|
||||
}
|
||||
|
||||
type AccSyncItemCollection {
|
||||
@@ -40,12 +40,12 @@ enum AccSyncItemStatus {
|
||||
|
||||
input DeleteAccSyncItemInput {
|
||||
projectId: ID!
|
||||
accFileLineageUrn: ID!
|
||||
id: ID!
|
||||
}
|
||||
|
||||
input UpdateAccSyncItemInput {
|
||||
projectId: ID!
|
||||
accFileLineageUrn: ID!
|
||||
id: ID!
|
||||
status: AccSyncItemStatus!
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ export type GetAccSyncItemByUrn = (args: {
|
||||
lineageUrn: string
|
||||
}) => Promise<AccSyncItem | null>
|
||||
|
||||
export type GetAccSyncItemById = (args: { id: string }) => Promise<AccSyncItem | null>
|
||||
|
||||
export type ListAccSyncItems = (args: {
|
||||
projectId: string
|
||||
filter?: {
|
||||
|
||||
@@ -14,7 +14,7 @@ export type AccSyncItem = {
|
||||
accFileExtension: string
|
||||
accFileVersionIndex: number
|
||||
accFileVersionUrn: string
|
||||
accFileViewName: string
|
||||
accFileViewName?: string | null
|
||||
accWebhookId?: string
|
||||
status: AccSyncItemStatus
|
||||
authorId: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
countAccSyncItemsFactory,
|
||||
deleteAccSyncItemByUrnFactory,
|
||||
getAccSyncItemByUrnFactory,
|
||||
getAccSyncItemByIdFactory,
|
||||
listAccSyncItemsFactory,
|
||||
updateAccSyncItemStatusFactory,
|
||||
upsertAccSyncItemFactory
|
||||
@@ -79,7 +79,6 @@ const resolvers: Resolvers = {
|
||||
const projectDb = await getProjectDbClient({ projectId: input.projectId })
|
||||
|
||||
return await createAccSyncItemFactory({
|
||||
getAccSyncItemByUrn: getAccSyncItemByUrnFactory({ db }),
|
||||
upsertAccSyncItem: upsertAccSyncItemFactory({ db }),
|
||||
createAutomation: createAutomationFactory({
|
||||
createAuthCode: createStoredAuthCodeFactory({ redis: getGenericRedis() }),
|
||||
@@ -137,7 +136,7 @@ const resolvers: Resolvers = {
|
||||
})
|
||||
|
||||
return await updateAccSyncItemFactory({
|
||||
getAccSyncItemByUrn: getAccSyncItemByUrnFactory({ db }),
|
||||
getAccSyncItemById: getAccSyncItemByIdFactory({ db }),
|
||||
upsertAccSyncItem: upsertAccSyncItemFactory({ db })
|
||||
})({
|
||||
syncItem: input
|
||||
@@ -186,7 +185,7 @@ const resolvers: Resolvers = {
|
||||
})
|
||||
},
|
||||
async accSyncItem(parent, args, ctx) {
|
||||
const { lineageUrn } = args
|
||||
const { id } = args
|
||||
|
||||
throwIfResourceAccessNotAllowed({
|
||||
resourceId: parent.id,
|
||||
@@ -195,8 +194,8 @@ const resolvers: Resolvers = {
|
||||
})
|
||||
|
||||
return await getAccSyncItemFactory({
|
||||
getAccSyncItemByUrn: getAccSyncItemByUrnFactory({ db })
|
||||
})({ lineageUrn })
|
||||
getAccSyncItemById: getAccSyncItemByIdFactory({ db })
|
||||
})({ id })
|
||||
}
|
||||
},
|
||||
Subscription: {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { AccSyncItems } from '@/modules/acc/dbSchema'
|
||||
import type {
|
||||
CountAccSyncItems,
|
||||
DeleteAccSyncItemByUrn,
|
||||
GetAccSyncItemById,
|
||||
GetAccSyncItemByUrn,
|
||||
ListAccSyncItems,
|
||||
QueryAllAccSyncItems,
|
||||
@@ -18,6 +19,18 @@ const tables = {
|
||||
accSyncItems: (db: Knex) => db<AccSyncItem>(AccSyncItems.name)
|
||||
}
|
||||
|
||||
export const getAccSyncItemByIdFactory =
|
||||
(deps: { db: Knex }): GetAccSyncItemById =>
|
||||
async ({ id }) => {
|
||||
return (
|
||||
(await tables
|
||||
.accSyncItems(deps.db)
|
||||
.select('*')
|
||||
.where(AccSyncItems.col.id, id)
|
||||
.first()) ?? null
|
||||
)
|
||||
}
|
||||
|
||||
export const getAccSyncItemByUrnFactory =
|
||||
(deps: { db: Knex }): GetAccSyncItemByUrn =>
|
||||
async ({ lineageUrn }) => {
|
||||
|
||||
@@ -9,12 +9,12 @@ import { isReadyForImport } from '@/modules/acc/domain/logic'
|
||||
import type {
|
||||
CountAccSyncItems,
|
||||
DeleteAccSyncItemByUrn,
|
||||
GetAccSyncItemByUrn,
|
||||
GetAccSyncItemById,
|
||||
ListAccSyncItems,
|
||||
UpsertAccSyncItem
|
||||
} from '@/modules/acc/domain/operations'
|
||||
import type { AccSyncItem } from '@/modules/acc/domain/types'
|
||||
import { DuplicateSyncItemError, SyncItemNotFoundError } from '@/modules/acc/errors/acc'
|
||||
import { SyncItemNotFoundError } from '@/modules/acc/errors/acc'
|
||||
import type { TriggerSyncItemAutomation } from '@/modules/acc/services/automate'
|
||||
import type {
|
||||
CreateAutomation,
|
||||
@@ -49,7 +49,6 @@ export type CreateAccSyncItem = (params: {
|
||||
|
||||
export const createAccSyncItemFactory =
|
||||
(deps: {
|
||||
getAccSyncItemByUrn: GetAccSyncItemByUrn
|
||||
upsertAccSyncItem: UpsertAccSyncItem
|
||||
createAutomation: CreateAutomation
|
||||
createAutomationRevision: CreateAutomationRevision
|
||||
@@ -57,14 +56,6 @@ export const createAccSyncItemFactory =
|
||||
eventEmit: EventBusEmit
|
||||
}): CreateAccSyncItem =>
|
||||
async ({ syncItem, creatorUserId }) => {
|
||||
const existingSyncItem = await deps.getAccSyncItemByUrn({
|
||||
lineageUrn: syncItem.accFileLineageUrn
|
||||
})
|
||||
|
||||
if (!!existingSyncItem) {
|
||||
throw new DuplicateSyncItemError(syncItem.accFileLineageUrn)
|
||||
}
|
||||
|
||||
const webhookId = await tryRegisterAccWebhook({
|
||||
// For local development, you may set your public tailscale url as your local server's canonical origin
|
||||
callbackUrl: `${getServerOrigin()}/api/v1/acc/webhook/callback`,
|
||||
@@ -145,12 +136,12 @@ export const createAccSyncItemFactory =
|
||||
return await deps.triggerSyncItemAutomation({ id: newSyncItem.id })
|
||||
}
|
||||
|
||||
export type GetAccSyncItem = (params: { lineageUrn: string }) => Promise<AccSyncItem>
|
||||
export type GetAccSyncItem = (params: { id: string }) => Promise<AccSyncItem>
|
||||
|
||||
export const getAccSyncItemFactory =
|
||||
(deps: { getAccSyncItemByUrn: GetAccSyncItemByUrn }): GetAccSyncItem =>
|
||||
async ({ lineageUrn }) => {
|
||||
const syncItem = await deps.getAccSyncItemByUrn({ lineageUrn })
|
||||
(deps: { getAccSyncItemById: GetAccSyncItemById }): GetAccSyncItem =>
|
||||
async ({ id }) => {
|
||||
const syncItem = await deps.getAccSyncItemById({ id })
|
||||
|
||||
if (!syncItem) {
|
||||
throw new SyncItemNotFoundError()
|
||||
@@ -200,17 +191,17 @@ export const getPaginatedAccSyncItemsFactory =
|
||||
}
|
||||
|
||||
export type UpdateAccSyncItem = (params: {
|
||||
syncItem: Pick<AccSyncItem, 'accFileLineageUrn' | 'status'>
|
||||
syncItem: Pick<AccSyncItem, 'accFileLineageUrn' | 'status' | 'id'>
|
||||
}) => Promise<AccSyncItem>
|
||||
|
||||
export const updateAccSyncItemFactory =
|
||||
(deps: {
|
||||
getAccSyncItemByUrn: GetAccSyncItemByUrn
|
||||
getAccSyncItemById: GetAccSyncItemById
|
||||
upsertAccSyncItem: UpsertAccSyncItem
|
||||
}): UpdateAccSyncItem =>
|
||||
async ({ syncItem }) => {
|
||||
const existingSyncItem = await deps.getAccSyncItemByUrn({
|
||||
lineageUrn: syncItem.accFileLineageUrn
|
||||
const existingSyncItem = await deps.getAccSyncItemById({
|
||||
id: syncItem.id
|
||||
})
|
||||
|
||||
if (!existingSyncItem) {
|
||||
|
||||
@@ -49,7 +49,7 @@ export type AccSyncItem = {
|
||||
accFileName: Scalars['String']['output'];
|
||||
accFileVersionIndex: Scalars['Int']['output'];
|
||||
accFileVersionUrn: Scalars['String']['output'];
|
||||
accFileViewName: Scalars['String']['output'];
|
||||
accFileViewName?: Maybe<Scalars['String']['output']>;
|
||||
accHubId: Scalars['String']['output'];
|
||||
accProjectId: Scalars['String']['output'];
|
||||
accRegion: Scalars['String']['output'];
|
||||
@@ -989,7 +989,7 @@ export type CreateAccSyncItemInput = {
|
||||
accFileName: Scalars['String']['input'];
|
||||
accFileVersionIndex: Scalars['Int']['input'];
|
||||
accFileVersionUrn: Scalars['String']['input'];
|
||||
accFileViewName: Scalars['String']['input'];
|
||||
accFileViewName?: InputMaybe<Scalars['String']['input']>;
|
||||
accHubId: Scalars['String']['input'];
|
||||
accProjectId: Scalars['String']['input'];
|
||||
accRegion: Scalars['String']['input'];
|
||||
@@ -1080,7 +1080,7 @@ export type CurrencyBasedPrices = {
|
||||
};
|
||||
|
||||
export type DeleteAccSyncItemInput = {
|
||||
accFileLineageUrn: Scalars['ID']['input'];
|
||||
id: Scalars['ID']['input'];
|
||||
projectId: Scalars['ID']['input'];
|
||||
};
|
||||
|
||||
@@ -4143,7 +4143,7 @@ export type TriggeredAutomationsStatus = {
|
||||
};
|
||||
|
||||
export type UpdateAccSyncItemInput = {
|
||||
accFileLineageUrn: Scalars['ID']['input'];
|
||||
id: Scalars['ID']['input'];
|
||||
projectId: Scalars['ID']['input'];
|
||||
status: AccSyncItemStatus;
|
||||
};
|
||||
@@ -6310,7 +6310,7 @@ export type AccSyncItemResolvers<ContextType = GraphQLContext, ParentType extend
|
||||
accFileName?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||
accFileVersionIndex?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
|
||||
accFileVersionUrn?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||
accFileViewName?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||
accFileViewName?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
|
||||
accHubId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||
accProjectId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||
accRegion?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
||||
|
||||
Reference in New Issue
Block a user