removed JSVM Collection class aliases
This commit is contained in:
		
							parent
							
								
									a446290a7a
								
							
						
					
					
						commit
						fadb4e3d67
					
				| 
						 | 
				
			
			@ -421,9 +421,6 @@ func baseBinds(vm *goja.Runtime) {
 | 
			
		|||
		instance := &core.Collection{}
 | 
			
		||||
		return structConstructorUnmarshal(vm, call, instance)
 | 
			
		||||
	})
 | 
			
		||||
	registerFactoryAsConstructor(vm, "BaseCollection", core.NewBaseCollection)
 | 
			
		||||
	registerFactoryAsConstructor(vm, "AuthCollection", core.NewAuthCollection)
 | 
			
		||||
	registerFactoryAsConstructor(vm, "ViewCollection", core.NewViewCollection)
 | 
			
		||||
 | 
			
		||||
	vm.Set("FieldsList", func(call goja.ConstructorCall) *goja.Object {
 | 
			
		||||
		instance := &core.FieldsList{}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ func TestBaseBindsCount(t *testing.T) {
 | 
			
		|||
	vm := goja.New()
 | 
			
		||||
	baseBinds(vm)
 | 
			
		||||
 | 
			
		||||
	testBindsCount(vm, "this", 35, t)
 | 
			
		||||
	testBindsCount(vm, "this", 32, t)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestBaseBindsSleep(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -293,42 +293,6 @@ func TestBaseBindsCollection(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestBaseBindsCollectionFactories(t *testing.T) {
 | 
			
		||||
	vm := goja.New()
 | 
			
		||||
	baseBinds(vm)
 | 
			
		||||
 | 
			
		||||
	scenarios := []struct {
 | 
			
		||||
		js           string
 | 
			
		||||
		expectedType string
 | 
			
		||||
	}{
 | 
			
		||||
		{"new BaseCollection('test')", core.CollectionTypeBase},
 | 
			
		||||
		{"new ViewCollection('test')", core.CollectionTypeView},
 | 
			
		||||
		{"new AuthCollection('test')", core.CollectionTypeAuth},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, s := range scenarios {
 | 
			
		||||
		t.Run(s.js, func(t *testing.T) {
 | 
			
		||||
			v, err := vm.RunString(s.js)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				t.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			c, ok := v.Export().(*core.Collection)
 | 
			
		||||
			if !ok {
 | 
			
		||||
				t.Fatalf("Expected *core.Collection instance, got %T (%v)", c, c)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if c.Name != "test" {
 | 
			
		||||
				t.Fatalf("Expected collection name %q, got %v", "test", c.Name)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if c.Type != s.expectedType {
 | 
			
		||||
				t.Fatalf("Expected collection type %q, got %v", s.expectedType, c.Type)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestBaseBindsFieldsList(t *testing.T) {
 | 
			
		||||
	vm := goja.New()
 | 
			
		||||
	baseBinds(vm)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -297,14 +297,16 @@ declare const Record: {
 | 
			
		|||
  // note: declare as "newable" const due to conflict with the Record TS utility type
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Collection extends core.Collection{} // merge
 | 
			
		||||
interface Collection extends core.Collection{
 | 
			
		||||
  type: "base" | "view" | "auth"
 | 
			
		||||
} // merge
 | 
			
		||||
/**
 | 
			
		||||
 * Collection model class.
 | 
			
		||||
 *
 | 
			
		||||
 * ` + "```" + `js
 | 
			
		||||
 * const collection = new Collection({
 | 
			
		||||
 *     name:       "article",
 | 
			
		||||
 *     type:       "base",
 | 
			
		||||
 *     name:       "article",
 | 
			
		||||
 *     listRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     viewRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     deleteRule: "@request.auth.id != ''",
 | 
			
		||||
| 
						 | 
				
			
			@ -327,91 +329,7 @@ interface Collection extends core.Collection{} // merge
 | 
			
		|||
 * @group PocketBase
 | 
			
		||||
 */
 | 
			
		||||
declare class Collection implements core.Collection {
 | 
			
		||||
  constructor(data?: Partial<core.Collection>)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface BaseCollection extends core.Collection{} // merge
 | 
			
		||||
/**
 | 
			
		||||
 * Alias for a "base" collection class.
 | 
			
		||||
 *
 | 
			
		||||
 * ` + "```" + `js
 | 
			
		||||
 * const collection = new BaseCollection({
 | 
			
		||||
 *     name:       "article",
 | 
			
		||||
 *     listRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     viewRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     deleteRule: "@request.auth.id != ''",
 | 
			
		||||
 *     fields: [
 | 
			
		||||
 *         {
 | 
			
		||||
 *             name: "title",
 | 
			
		||||
 *             type: "text",
 | 
			
		||||
 *             required: true,
 | 
			
		||||
 *             min: 6,
 | 
			
		||||
 *             max: 100,
 | 
			
		||||
 *         },
 | 
			
		||||
 *         {
 | 
			
		||||
 *             name: "description",
 | 
			
		||||
 *             type: "text",
 | 
			
		||||
 *         },
 | 
			
		||||
 *     ]
 | 
			
		||||
 * })
 | 
			
		||||
 * ` + "```" + `
 | 
			
		||||
 *
 | 
			
		||||
 * @group PocketBase
 | 
			
		||||
 */
 | 
			
		||||
declare class BaseCollection implements core.Collection {
 | 
			
		||||
  constructor(data?: Partial<core.Collection>)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface AuthCollection extends core.Collection{} // merge
 | 
			
		||||
/**
 | 
			
		||||
 * Alias for an "auth" collection class.
 | 
			
		||||
 *
 | 
			
		||||
 * ` + "```" + `js
 | 
			
		||||
 * const collection = new AuthCollection({
 | 
			
		||||
 *     name:       "clients",
 | 
			
		||||
 *     listRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     viewRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     deleteRule: "@request.auth.id != ''",
 | 
			
		||||
 *     fields: [
 | 
			
		||||
 *         {
 | 
			
		||||
 *             name: "title",
 | 
			
		||||
 *             type: "text",
 | 
			
		||||
 *             required: true,
 | 
			
		||||
 *             min: 6,
 | 
			
		||||
 *             max: 100,
 | 
			
		||||
 *         },
 | 
			
		||||
 *         {
 | 
			
		||||
 *             name: "description",
 | 
			
		||||
 *             type: "text",
 | 
			
		||||
 *         },
 | 
			
		||||
 *     ]
 | 
			
		||||
 * })
 | 
			
		||||
 * ` + "```" + `
 | 
			
		||||
 *
 | 
			
		||||
 * @group PocketBase
 | 
			
		||||
 */
 | 
			
		||||
declare class AuthCollection implements core.Collection {
 | 
			
		||||
  constructor(data?: Partial<core.Collection>)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ViewCollection extends core.Collection{} // merge
 | 
			
		||||
/**
 | 
			
		||||
 * Alias for a "view" collection class.
 | 
			
		||||
 *
 | 
			
		||||
 * ` + "```" + `js
 | 
			
		||||
 * const collection = new ViewCollection({
 | 
			
		||||
 *     name:       "clients",
 | 
			
		||||
 *     listRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     viewRule:   "@request.auth.id != '' || status = 'public'",
 | 
			
		||||
 *     deleteRule: "@request.auth.id != ''",
 | 
			
		||||
 *     viewQuery:  "SELECT id, title from posts",
 | 
			
		||||
 * })
 | 
			
		||||
 * ` + "```" + `
 | 
			
		||||
 *
 | 
			
		||||
 * @group PocketBase
 | 
			
		||||
 */
 | 
			
		||||
declare class ViewCollection implements core.Collection {
 | 
			
		||||
  constructor(data?: Partial<core.Collection>)
 | 
			
		||||
  constructor(data?: Partial<Collection>)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface FieldsList extends core.FieldsList{} // merge
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue