Skip to content

Commit

Permalink
Implement workarounds for parse erroring on start
Browse files Browse the repository at this point in the history
The workaround is to use the minimized parse distribution

Issues described more fully here: parse-community/Parse-SDK-JS#1362
  • Loading branch information
gnu-lorien committed Feb 5, 2023
1 parent cd852f8 commit f506cf2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 6 deletions.
36 changes: 36 additions & 0 deletions src/models/SampleVampire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Parse from 'parse/dist/parse.min.js'

export class SampleVampire extends Parse.Object {
constructor() {
super('Vampire')
}

static async progress(text) {
console.log(`Progress: ${text}`)
}

static async create(name) {
const v = new this()
const acl = new Parse.ACL()
acl.setPublicReadAccess(false)
acl.setPublicWriteAccess(false)
acl.setWriteAccess(Parse.User.current(), true)
acl.setReadAccess(Parse.User.current(), true)
acl.setRoleReadAccess('Administrator', true)
acl.setRoleWriteAccess('Administrator', true)
v.setACL(acl)
this.progress('Fetching patronage status')
await v.save({
name,
owner: Parse.User.current(),
change_count: 0,
})
return v
}

static async create_test_character(nameappend) {
nameappend = nameappend || ''
const name = `kct_${nameappend}_${Math.random().toString(36).slice(2)}`
return await this.create(name)
}
}
2 changes: 1 addition & 1 deletion src/models/Vampire.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Parse from 'parse'
import Parse from 'parse/dist/parse.min.js'

const ALL_SIMPLETRAIT_CATEGORIES = [
['attributes', 'Attributes', 'Attributes'],
Expand Down
3 changes: 2 additions & 1 deletion src/modules/parsetypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Parse from 'parse'
import Parse from 'parse/dist/parse.min.js'
import { type UserModule } from '~/types'
import { Vampire } from '~/models/Vampire'
import { SampleVampire } from '~/models/SampleVampire'

export function registerYorickTypes() {
Parse.Object.registerSubclass('Vampire', Vampire)
Expand Down
4 changes: 2 additions & 2 deletions src/stores/patronage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type Parse from 'parse'
import type Parse from 'parse/dist/parse.min.js'
import { acceptHMRUpdate, defineStore } from 'pinia'

export const usePatronageStore = defineStore('patronage', () => {
const patronages = reactive([])

async function getLatestPatronage(user: Parse.User) {

return {}
}
/**
* Current name of the user.
Expand Down
14 changes: 13 additions & 1 deletion test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { describe, expect, it } from 'vitest'
import { Parse } from 'parse/node'
// import { Parse } from 'parse/node'
import Parse from 'parse/dist/parse.min.js'
import { useConfigTestDefault } from '~/composables/siteconfig'
import { SampleVampire } from '~/models/SampleVampire'

describe('tests', () => {
it('should works', () => {
Expand All @@ -19,3 +21,13 @@ describe('parse sanity', () => {
expect(results[0].get('name')).toBe('Orthodox')
})
})

describe('Vampires', () => {
it('Create a sample vampire', async () => {
Parse.initialize('APPLICATION_ID')
Parse.serverURL = useConfigTestDefault().serverURL
const u = await Parse.User.logIn('devuser', 'thedumbness')
const v = await SampleVampire.create_test_character('saymsamp')
expect(v.get('name')).to.be.a('string').and.satisfy(msg => msg.startsWith('kct_saymsamp'))
})
})
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"unplugin-vue-macros/macros-global"
],
"paths": {
"~/*": ["src/*"]
"~/*": ["src/*"],
"parse/dist/parse.min": ["node_modules/@types/parse/index.d.ts"],
"parse/dist/parse.min.js": ["node_modules/@types/parse/index.d.ts"]
}
},
"vueCompilerOptions": {
Expand Down

0 comments on commit f506cf2

Please sign in to comment.