feat(modules-sdk): Remote Query (#4463)

* feat: Remote Query
This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2023-07-19 15:35:36 -03:00
1 parent 95c538c675
commit 5a8a889c6d
57 files changed
+1286 -423

No files matched your search

+1 -1
View File
@@ -1,2 +1,2 @@
export * from "./common"
export * from "./inventory"
export * from "./service"
@@ -13,9 +13,11 @@ import {
} from "./common"
import { FindConfig } from "../common"
import { JoinerServiceConfig } from "../joiner"
import { SharedContext } from ".."
export interface IInventoryService {
__joinerConfig(): JoinerServiceConfig
listInventoryItems(
selector: FilterableInventoryItemProps,
config?: FindConfig<InventoryItemDTO>,
@@ -72,12 +74,12 @@ export interface IInventoryService {
): Promise<InventoryItemDTO[]>
createInventoryLevel(
data: CreateInventoryLevelInput ,
data: CreateInventoryLevelInput,
context?: SharedContext
): Promise<InventoryLevelDTO>
createInventoryLevels(
data: CreateInventoryLevelInput[],
data: CreateInventoryLevelInput[],
context?: SharedContext
): Promise<InventoryLevelDTO[]>
+12 -2
View File
@@ -4,16 +4,25 @@ export type JoinerRelationship = {
primaryKey: string
serviceName: string
inverse?: boolean // In an inverted relationship the foreign key is on the other service and the primary key is on the current service
isList?: boolean // Force the relationship to return a list
args?: Record<string, any> // Extra arguments to pass to the remoteFetchData callback
}
export interface JoinerServiceConfigAlias {
name: string
args?: Record<string, any> // Extra arguments to pass to the remoteFetchData callback
}
export interface JoinerServiceConfig {
serviceName: string
alias?: JoinerServiceConfigAlias | JoinerServiceConfigAlias[] // Property name to use as entrypoint to the service
primaryKeys: string[]
relationships?: JoinerRelationship[]
extends?: {
serviceName: string
resolve: JoinerRelationship
relationship: JoinerRelationship
}[]
args?: Record<string, any> // Extra arguments to pass to the remoteFetchData callback
}
export interface JoinerArgument {
@@ -23,7 +32,8 @@ export interface JoinerArgument {
}
export interface RemoteJoinerQuery {
service: string
service?: string
alias?: string
expands?: Array<{
property: string
fields: string[]
+5
View File
@@ -31,6 +31,8 @@ export type InternalModuleDeclaration = {
dependencies?: string[]
resolve?: string
options?: Record<string, unknown>
alias?: string // If multiple modules are registered with the same key, the alias can be used to differentiate them
main?: boolean // If the module is the main module for the key when multiple ones are registered
}
export type ExternalModuleDeclaration = {
@@ -40,6 +42,8 @@ export type ExternalModuleDeclaration = {
url: string
keepAlive: boolean
}
alias?: string // If multiple modules are registered with the same key, the alias can be used to differentiate them
main?: boolean // If the module is the main module for the key when multiple ones are registered
}
export type ModuleResolution = {
@@ -58,6 +62,7 @@ export type ModuleDefinition = {
label: string
canOverride?: boolean
isRequired?: boolean
isQueryable?: boolean // If the modules should be queryable via Remote Joiner
dependencies?: string[]
defaultModuleDeclaration:
| InternalModuleDeclaration
+1 -1
View File
@@ -1,2 +1,2 @@
export * from "./service"
export * from "./common"
export * from "./service"
+5 -1
View File
@@ -11,10 +11,14 @@ import {
ProductTagDTO,
ProductVariantDTO,
} from "./common"
import { FindConfig } from "../common"
import { Context } from "../shared-context"
import { FindConfig } from "../common"
import { JoinerServiceConfig } from "../joiner"
export interface IProductModuleService {
__joinerConfig(): JoinerServiceConfig
retrieve(productId: string, sharedContext?: Context): Promise<ProductDTO>
list(
+1 -1
View File
@@ -1,2 +1,2 @@
export * from "./common"
export * from "./stock-location"
export * from "./service"
@@ -0,0 +1,43 @@
import { FindConfig } from "../common/common"
import { JoinerServiceConfig } from "../joiner"
import { SharedContext } from "../shared-context"
import {
CreateStockLocationInput,
FilterableStockLocationProps,
StockLocationDTO,
UpdateStockLocationInput,
} from "./common"
export interface IStockLocationService {
__joinerConfig(): JoinerServiceConfig
list(
selector: FilterableStockLocationProps,
config?: FindConfig<StockLocationDTO>,
context?: SharedContext
): Promise<StockLocationDTO[]>
listAndCount(
selector: FilterableStockLocationProps,
config?: FindConfig<StockLocationDTO>,
context?: SharedContext
): Promise<[StockLocationDTO[], number]>
retrieve(
id: string,
config?: FindConfig<StockLocationDTO>,
context?: SharedContext
): Promise<StockLocationDTO>
create(
input: CreateStockLocationInput,
context?: SharedContext
): Promise<StockLocationDTO>
update(
id: string,
input: UpdateStockLocationInput,
context?: SharedContext
): Promise<StockLocationDTO>
delete(id: string, context?: SharedContext): Promise<void>
}